Преглед на файлове

Alternative to mg_upload (Step 36/?)

bel преди 9 години
родител
ревизия
efa1fe9883
променени са 3 файла, в които са добавени 16 реда и са изтрити 12 реда
  1. 1 0
      VS2012/ex_embedded_c/ex_embedded_c.vcxproj
  2. 0 1
      src/civetweb.c
  3. 15 11
      src/handle_form.inl

+ 1 - 0
VS2012/ex_embedded_c/ex_embedded_c.vcxproj

@@ -101,6 +101,7 @@
     <Link>
     <Link>
       <SubSystem>Console</SubSystem>
       <SubSystem>Console</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

+ 0 - 1
src/civetweb.c

@@ -12407,7 +12407,6 @@ get_system_name(char **sysName)
 #endif
 #endif
 }
 }
 
 
-
 struct mg_context *
 struct mg_context *
 mg_start(const struct mg_callbacks *callbacks,
 mg_start(const struct mg_callbacks *callbacks,
          void *user_data,
          void *user_data,

+ 15 - 11
src/handle_form.inl

@@ -443,10 +443,11 @@ mg_handle_form_data(struct mg_connection *conn,
 			if (buf[bl + 2] != '\r' || buf[bl + 3] != '\n') {
 			if (buf[bl + 2] != '\r' || buf[bl + 3] != '\n') {
 				/* Every part must end with \r\n, if there is another part.
 				/* Every part must end with \r\n, if there is another part.
 				 * The end of the request has an extra -- */
 				 * The end of the request has an extra -- */
-				if ((buf_fill != (bl + 6)) || (strncmp(buf + bl + 2, "--\r\n", 4))) {
+				if (((size_t)buf_fill != (size_t)(bl + 6))
+				    || (strncmp(buf + bl + 2, "--\r\n", 4))) {
 					/* Malformed request */
 					/* Malformed request */
 					return 0;
 					return 0;
-				}                
+				}
 				/* End of the request */
 				/* End of the request */
 				break;
 				break;
 			}
 			}
@@ -574,19 +575,22 @@ mg_handle_form_data(struct mg_connection *conn,
 							return 0;
 							return 0;
 						}
 						}
 
 
-                        /* Find boundary */
-                        next = strstr(hbuf, "\r\n--");
-			            while (next && (strncmp(next + 4, boundary, bl))) {
-				            /* found "--" not followed by boundary: look for next "--" */
-				            next = strstr(next + 1, "\r\n--");
-			            }
+						/* Find boundary */
+						next = strstr(hbuf, "\r\n--");
+						while (next && (strncmp(next + 4, boundary, bl))) {
+							/* found "--" not followed by boundary: look for
+							 * next "--" */
+							next = strstr(next + 1, "\r\n--");
+						}
 
 
-                        /* TODO (high): handle boundary split between two chunks */
+						/* TODO (high): handle boundaries split between two
+						   chunks
+						   part of the chunk here, part of the chunk yet unread
+						 */
 					}
 					}
 
 
-
 					if (fstore) {
 					if (fstore) {
-						size_t towrite = (size_t)(next - hend - 4);
+						towrite = (size_t)(next - hend - 4);
 						n = (size_t)fwrite(hend + 4, 1, towrite, fstore);
 						n = (size_t)fwrite(hend + 4, 1, towrite, fstore);
 						if ((n != towrite) || (ferror(fstore))) {
 						if ((n != towrite) || (ferror(fstore))) {
 							mg_cry(conn,
 							mg_cry(conn,