diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/daemon/connection.c | 13 | ||||
-rw-r--r-- | src/daemon/internal.h | 9 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/daemon/connection.c b/src/daemon/connection.c index dde49962..d99a88c2 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c | |||
@@ -813,11 +813,11 @@ MHD_test_post_data (struct MHD_Connection *connection) | |||
813 | { | 813 | { |
814 | buf = MHD_pool_reallocate (connection->pool, | 814 | buf = MHD_pool_reallocate (connection->pool, |
815 | connection->read_buffer, | 815 | connection->read_buffer, |
816 | connection->read_buffer_size, | 816 | (connection->read_buffer == NULL) ? 0 : connection->read_buffer_size + 1, |
817 | connection->uploadSize + 1); | 817 | connection->uploadSize + 1); |
818 | if (buf == NULL) | 818 | if (buf == NULL) |
819 | return MHD_NO; | 819 | return MHD_NO; |
820 | connection->read_buffer_size = connection->uploadSize + 1; | 820 | connection->read_buffer_size = connection->uploadSize; |
821 | connection->read_buffer = buf; | 821 | connection->read_buffer = buf; |
822 | return MHD_YES; | 822 | return MHD_YES; |
823 | } | 823 | } |
@@ -851,6 +851,9 @@ MHD_parse_post_data (struct MHD_Connection *connection) | |||
851 | return MHD_NO; | 851 | return MHD_NO; |
852 | if (0 == strcasecmp (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, encoding)) | 852 | if (0 == strcasecmp (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, encoding)) |
853 | { | 853 | { |
854 | /* add 0-termination, that's why the actual buffer size | ||
855 | is always 1 more than what is actually required for the data! */ | ||
856 | connection->read_buffer[connection->readLoc] = '\0'; | ||
854 | ret = parse_arguments (MHD_POSTDATA_KIND, | 857 | ret = parse_arguments (MHD_POSTDATA_KIND, |
855 | connection, connection->read_buffer); | 858 | connection, connection->read_buffer); |
856 | /* invalidate read buffer for other uses -- | 859 | /* invalidate read buffer for other uses -- |
@@ -924,6 +927,10 @@ MHD_call_connection_handler (struct MHD_Connection *connection) | |||
924 | (connection->uploadSize == -1) && (connection->socket_fd == -1))) | 927 | (connection->uploadSize == -1) && (connection->socket_fd == -1))) |
925 | { | 928 | { |
926 | connection->bodyReceived = 1; | 929 | connection->bodyReceived = 1; |
930 | MHD_pool_reallocate(connection->pool, | ||
931 | (connection->read_buffer == NULL) ? 0 : connection->read_buffer_size + 1, | ||
932 | connection->read_buffer_size, | ||
933 | 0); | ||
927 | connection->readLoc = 0; | 934 | connection->readLoc = 0; |
928 | connection->read_buffer_size = 0; | 935 | connection->read_buffer_size = 0; |
929 | connection->read_buffer = NULL; | 936 | connection->read_buffer = NULL; |
@@ -959,7 +966,7 @@ MHD_connection_handle_read (struct MHD_Connection *connection) | |||
959 | connection->read_buffer, | 966 | connection->read_buffer, |
960 | connection->read_buffer_size, | 967 | connection->read_buffer_size, |
961 | connection->read_buffer_size * 2 + | 968 | connection->read_buffer_size * 2 + |
962 | MHD_BUF_INC_SIZE); | 969 | MHD_BUF_INC_SIZE + 1); |
963 | if (tmp == NULL) | 970 | if (tmp == NULL) |
964 | { | 971 | { |
965 | MHD_DLOG (connection->daemon, | 972 | MHD_DLOG (connection->daemon, |
diff --git a/src/daemon/internal.h b/src/daemon/internal.h index b6f8336e..125755d2 100644 --- a/src/daemon/internal.h +++ b/src/daemon/internal.h | |||
@@ -230,7 +230,9 @@ struct MHD_Connection | |||
230 | 230 | ||
231 | /** | 231 | /** |
232 | * Buffer for reading requests. Allocated | 232 | * Buffer for reading requests. Allocated |
233 | * in pool. | 233 | * in pool. Actually one byte larger than |
234 | * read_buffer_size (if non-NULL) to allow for | ||
235 | * 0-termination. | ||
234 | */ | 236 | */ |
235 | char *read_buffer; | 237 | char *read_buffer; |
236 | 238 | ||
@@ -253,7 +255,10 @@ struct MHD_Connection | |||
253 | pthread_t pid; | 255 | pthread_t pid; |
254 | 256 | ||
255 | /** | 257 | /** |
256 | * Size of read_buffer (in bytes). | 258 | * Size of read_buffer (in bytes). This value indicates |
259 | * how many bytes we're willing to read into the buffer; | ||
260 | * the real buffer is one byte longer to allow for | ||
261 | * adding zero-termination (when needed). | ||
257 | */ | 262 | */ |
258 | size_t read_buffer_size; | 263 | size_t read_buffer_size; |
259 | 264 | ||