Procházet zdrojové kódy

Fix bug found in file upload test (see also issue #36)

bel před 10 roky
rodič
revize
c4f4d28ac5
1 změnil soubory, kde provedl 4 přidání a 3 odebrání
  1. 4 3
      src/civetweb.c

+ 4 - 3
src/civetweb.c

@@ -2307,9 +2307,10 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len)
     nread = 0;
     if (conn->consumed_content < conn->content_len) {
         /* Adjust number of bytes to read. */
-        int64_t to_read = conn->content_len - conn->consumed_content;
-        if (to_read < len64) {
-            len = (size_t) to_read;
+        int64_t left_to_read = conn->content_len - conn->consumed_content;
+        if (left_to_read < len64) {
+            /* Do not reade more than the total content length of the request. */
+            len64 = left_to_read;
         }
 
         /* Return buffered data */