diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-08-01 00:54:42 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-08-01 00:54:42 +0200 |
commit | de315d36e01a089063c2e76bb26a6e705365cf66 (patch) | |
tree | 1db56aa3bf427384fb38a71f96864374c75ca21b /src/microhttpd/connection.c | |
parent | bafd078984be5f846287107824eca99e6c6c42cc (diff) | |
download | libmicrohttpd-de315d36e01a089063c2e76bb26a6e705365cf66.tar.gz libmicrohttpd-de315d36e01a089063c2e76bb26a6e705365cf66.zip |
attempt to fix issue with upload data discovered by FD
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r-- | src/microhttpd/connection.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index fd977708..6f33dbc1 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -2624,7 +2624,19 @@ process_request_body (struct MHD_Connection *connection) | |||
2624 | char *buffer_head; | 2624 | char *buffer_head; |
2625 | 2625 | ||
2626 | if (NULL != connection->response) | 2626 | if (NULL != connection->response) |
2627 | return; /* already queued a response */ | 2627 | { |
2628 | /* already queued a response, discard remaining upload | ||
2629 | (but not more, there might be another request after it) */ | ||
2630 | uint64_t purge = MHD_MIN (connection->remaining_upload_size, | ||
2631 | connection->read_buffer_offset); | ||
2632 | connection->remaining_upload_size -= purge; | ||
2633 | if (connection->read_buffer_offset > purge) | ||
2634 | memmove (connection->read_buffer, | ||
2635 | &connection->read_buffer[purge], | ||
2636 | connection->read_buffer_offset - purge); | ||
2637 | connection->read_buffer_offset -= purge; | ||
2638 | return; | ||
2639 | } | ||
2628 | 2640 | ||
2629 | buffer_head = connection->read_buffer; | 2641 | buffer_head = connection->read_buffer; |
2630 | available = connection->read_buffer_offset; | 2642 | available = connection->read_buffer_offset; |
@@ -2759,19 +2771,19 @@ process_request_body (struct MHD_Connection *connection) | |||
2759 | { | 2771 | { |
2760 | /* no chunked encoding, give all to the client */ | 2772 | /* no chunked encoding, give all to the client */ |
2761 | if ( (0 != connection->remaining_upload_size) && | 2773 | if ( (0 != connection->remaining_upload_size) && |
2762 | (MHD_SIZE_UNKNOWN != connection->remaining_upload_size) && | 2774 | (MHD_SIZE_UNKNOWN != connection->remaining_upload_size) && |
2763 | (connection->remaining_upload_size < available) ) | 2775 | (connection->remaining_upload_size < available) ) |
2764 | { | 2776 | { |
2765 | to_be_processed = (size_t)connection->remaining_upload_size; | 2777 | to_be_processed = (size_t)connection->remaining_upload_size; |
2766 | } | 2778 | } |
2767 | else | 2779 | else |
2768 | { | 2780 | { |
2769 | /** | 2781 | /** |
2770 | * 1. no chunked encoding, give all to the client | 2782 | * 1. no chunked encoding, give all to the client |
2771 | * 2. client may send large chunked data, but only a smaller part is available at one time. | 2783 | * 2. client may send large chunked data, but only a smaller part is available at one time. |
2772 | */ | 2784 | */ |
2773 | to_be_processed = available; | 2785 | to_be_processed = available; |
2774 | } | 2786 | } |
2775 | } | 2787 | } |
2776 | left_unprocessed = to_be_processed; | 2788 | left_unprocessed = to_be_processed; |
2777 | connection->client_aware = true; | 2789 | connection->client_aware = true; |