aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/postprocessor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/postprocessor.c')
-rw-r--r--src/microhttpd/postprocessor.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/microhttpd/postprocessor.c b/src/microhttpd/postprocessor.c
index 8848b306..1eb33ed6 100644
--- a/src/microhttpd/postprocessor.c
+++ b/src/microhttpd/postprocessor.c
@@ -137,8 +137,7 @@ struct MHD_PostProcessor
137 void *cls; 137 void *cls;
138 138
139 /** 139 /**
140 * Encoding as given by the headers of the 140 * Encoding as given by the headers of the connection.
141 * connection.
142 */ 141 */
143 const char *encoding; 142 const char *encoding;
144 143
@@ -590,7 +589,7 @@ post_process_urlencoded (struct MHD_PostProcessor *pp,
590 pp->state = PP_Error; 589 pp->state = PP_Error;
591 break; 590 break;
592 case PP_Callback: 591 case PP_Callback:
593 if ( (pp->buffer_pos + (end_key - start_key) > 592 if ( (pp->buffer_pos + (end_key - start_key) >=
594 pp->buffer_size) || 593 pp->buffer_size) ||
595 (pp->buffer_pos + (end_key - start_key) < 594 (pp->buffer_pos + (end_key - start_key) <
596 pp->buffer_pos) ) 595 pp->buffer_pos) )
@@ -640,6 +639,11 @@ post_process_urlencoded (struct MHD_PostProcessor *pp,
640 { 639 {
641 if (NULL == end_key) 640 if (NULL == end_key)
642 end_key = &post_data[poff]; 641 end_key = &post_data[poff];
642 if (pp->buffer_pos + (end_key - start_key) >= pp->buffer_size)
643 {
644 pp->state = PP_Error;
645 return MHD_NO;
646 }
643 memcpy (&kbuf[pp->buffer_pos], 647 memcpy (&kbuf[pp->buffer_pos],
644 start_key, 648 start_key,
645 end_key - start_key); 649 end_key - start_key);
@@ -667,6 +671,11 @@ post_process_urlencoded (struct MHD_PostProcessor *pp,
667 last_escape); 671 last_escape);
668 pp->must_ikvi = false; 672 pp->must_ikvi = false;
669 } 673 }
674 if (PP_Error == pp->state)
675 {
676 /* State in error, returning failure */
677 return MHD_NO;
678 }
670 return MHD_YES; 679 return MHD_YES;
671} 680}
672 681
@@ -1428,7 +1437,8 @@ MHD_destroy_post_processor (struct MHD_PostProcessor *pp)
1428 the post-processing may have been interrupted 1437 the post-processing may have been interrupted
1429 at any stage */ 1438 at any stage */
1430 if ( (pp->xbuf_pos > 0) || 1439 if ( (pp->xbuf_pos > 0) ||
1431 (pp->state != PP_Done) ) 1440 ( (pp->state != PP_Done) &&
1441 (pp->state != PP_Init) ) )
1432 ret = MHD_NO; 1442 ret = MHD_NO;
1433 else 1443 else
1434 ret = MHD_YES; 1444 ret = MHD_YES;