aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-08-01 00:54:42 +0200
committerChristian Grothoff <christian@grothoff.org>2019-08-01 00:54:42 +0200
commitde315d36e01a089063c2e76bb26a6e705365cf66 (patch)
tree1db56aa3bf427384fb38a71f96864374c75ca21b
parentbafd078984be5f846287107824eca99e6c6c42cc (diff)
downloadlibmicrohttpd-de315d36e01a089063c2e76bb26a6e705365cf66.tar.gz
libmicrohttpd-de315d36e01a089063c2e76bb26a6e705365cf66.zip
attempt to fix issue with upload data discovered by FD
-rw-r--r--ChangeLog4
-rw-r--r--src/include/microhttpd.h2
-rw-r--r--src/microhttpd/connection.c26
3 files changed, 24 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index b4c065c8..87de3ef9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
1Thu 01 Aug 2019 12:53:49 AM CEST
2 Fix issue with discarding unhandled upload data discovered
3 by Florian Dold. -CG
4
1Mon 29 Jul 2019 08:01:50 PM CEST 5Mon 29 Jul 2019 08:01:50 PM CEST
2 Fix hanging situation with large transmission over upgraded 6 Fix hanging situation with large transmission over upgraded
3 (i.e. Web socket) connection with epoll() and HTTPS enabled 7 (i.e. Web socket) connection with epoll() and HTTPS enabled
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index f141967c..a2196b9d 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -132,7 +132,7 @@ typedef intptr_t ssize_t;
132 * Current version of the library. 132 * Current version of the library.
133 * 0x01093001 = 1.9.30-1. 133 * 0x01093001 = 1.9.30-1.
134 */ 134 */
135#define MHD_VERSION 0x00096504 135#define MHD_VERSION 0x00096505
136 136
137/** 137/**
138 * MHD-internal return code for "YES". 138 * MHD-internal return code for "YES".
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;