aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2008-05-23 22:49:29 +0000
committerChristian Grothoff <christian@grothoff.org>2008-05-23 22:49:29 +0000
commit43f13d6f3b84b693f64b015b9242e3fcf59ec39b (patch)
tree7f536c39af7d75cfe3cf5526dacff7a2c97bf829
parente7783a687eadd469a06b5fe2c0e52d700a735cf0 (diff)
downloadlibmicrohttpd-43f13d6f3b84b693f64b015b9242e3fcf59ec39b.tar.gz
libmicrohttpd-43f13d6f3b84b693f64b015b9242e3fcf59ec39b.zip
fixing issue with large urlencoded uploads
-rw-r--r--src/daemon/postprocessor.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/daemon/postprocessor.c b/src/daemon/postprocessor.c
index 43c0376f..45713ed1 100644
--- a/src/daemon/postprocessor.c
+++ b/src/daemon/postprocessor.c
@@ -310,6 +310,7 @@ post_process_urlencoded (struct MHD_PostProcessor *pp,
310 unsigned int poff; 310 unsigned int poff;
311 unsigned int xoff; 311 unsigned int xoff;
312 unsigned int delta; 312 unsigned int delta;
313 int end_of_value_found;
313 char *buf; 314 char *buf;
314 char xbuf[XBUF_SIZE + 1]; 315 char xbuf[XBUF_SIZE + 1];
315 316
@@ -355,11 +356,14 @@ post_process_urlencoded (struct MHD_PostProcessor *pp,
355 /* find last position in input buffer that is part of the value */ 356 /* find last position in input buffer that is part of the value */
356 amper = 0; 357 amper = 0;
357 while ((amper + poff < post_data_len) && 358 while ((amper + poff < post_data_len) &&
359 (amper < XBUF_SIZE) &&
358 (post_data[amper + poff] != '&') && 360 (post_data[amper + poff] != '&') &&
359 (post_data[amper + poff] != '\n') && 361 (post_data[amper + poff] != '\n') &&
360 (post_data[amper + poff] != '\r')) 362 (post_data[amper + poff] != '\r'))
361 amper++; 363 amper++;
362 364 end_of_value_found = ( (post_data[amper + poff] == '&') ||
365 (post_data[amper + poff] == '\n') ||
366 (post_data[amper + poff] == '\r') );
363 /* compute delta, the maximum number of bytes that we will be able to 367 /* compute delta, the maximum number of bytes that we will be able to
364 process right now (either amper-limited of xbuf-size limited) */ 368 process right now (either amper-limited of xbuf-size limited) */
365 delta = amper; 369 delta = amper;
@@ -400,12 +404,17 @@ post_process_urlencoded (struct MHD_PostProcessor *pp,
400 MHD_http_unescape (xbuf); 404 MHD_http_unescape (xbuf);
401 405
402 /* finally: call application! */ 406 /* finally: call application! */
403 pp->ikvi (pp->cls, MHD_POSTDATA_KIND, (const char *) &pp[1], /* key */ 407 if (MHD_NO ==
404 NULL, NULL, NULL, xbuf, pp->value_offset, xoff); 408 pp->ikvi (pp->cls, MHD_POSTDATA_KIND, (const char *) &pp[1], /* key */
409 NULL, NULL, NULL, xbuf, pp->value_offset, xoff))
410 {
411 pp->state = PP_Error;
412 return MHD_NO;
413 }
405 pp->value_offset += xoff; 414 pp->value_offset += xoff;
406 415
407 /* are we done with the value? */ 416 /* are we done with the value? */
408 if (poff < post_data_len) 417 if (end_of_value_found)
409 { 418 {
410 /* we found the end of the value! */ 419 /* we found the end of the value! */
411 pp->state = PP_Init; 420 pp->state = PP_Init;