diff options
Diffstat (limited to 'src/daemon/connection.c')
-rw-r--r-- | src/daemon/connection.c | 13 |
1 files changed, 10 insertions, 3 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, |