소스 검색

Reset next pointer when handling url-encoded form data POST requests (#605)

bel2125 7 년 전
부모
커밋
13839585ed
1개의 변경된 파일7개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      src/handle_form.inl

+ 7 - 2
src/handle_form.inl

@@ -436,6 +436,7 @@ mg_handle_form_request(struct mg_connection *conn,
 				} else {
 					vallen = (ptrdiff_t)strlen(val);
 					next = val + vallen;
+					end_of_key_value_pair_found = all_data_read;
 				}
 
 				if (field_storage == MG_FORM_FIELD_STORAGE_GET) {
@@ -443,8 +444,6 @@ mg_handle_form_request(struct mg_connection *conn,
 					if (!end_of_key_value_pair_found && !all_data_read) {
 						/* This callback will deliver partial contents */
 					}
-#else
-					(void)all_data_read; /* avoid warning */
 #endif
 
 					/* Call callback */
@@ -476,6 +475,7 @@ mg_handle_form_request(struct mg_connection *conn,
 					memmove(buf,
 					        buf + (size_t)used,
 					        sizeof(buf) - (size_t)used);
+					next = buf;
 					buf_fill -= (int)used;
 					if ((size_t)buf_fill < (sizeof(buf) - 1)) {
 
@@ -523,6 +523,11 @@ mg_handle_form_request(struct mg_connection *conn,
 				fstore.access.fp = NULL;
 			}
 
+			if (all_data_read && (buf_fill == 0)) {
+				/* nothing more to process */
+				break;
+			}
+
 			/* Proceed to next entry */
 			used = next - buf;
 			memmove(buf, buf + (size_t)used, sizeof(buf) - (size_t)used);