diff options
Diffstat (limited to 'src/microhttpd')
-rw-r--r-- | src/microhttpd/connection.c | 43 | ||||
-rw-r--r-- | src/microhttpd/test_postprocessor.c | 2 |
2 files changed, 36 insertions, 9 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 13b5015b..1778c59b 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -1756,6 +1756,7 @@ transmit_error_response (struct MHD_Connection *connection, | |||
1756 | const char *message) | 1756 | const char *message) |
1757 | { | 1757 | { |
1758 | struct MHD_Response *response; | 1758 | struct MHD_Response *response; |
1759 | int iret; | ||
1759 | 1760 | ||
1760 | if (NULL == connection->version) | 1761 | if (NULL == connection->version) |
1761 | { | 1762 | { |
@@ -1779,11 +1780,24 @@ transmit_error_response (struct MHD_Connection *connection, | |||
1779 | response = MHD_create_response_from_buffer (strlen (message), | 1780 | response = MHD_create_response_from_buffer (strlen (message), |
1780 | (void *) message, | 1781 | (void *) message, |
1781 | MHD_RESPMEM_PERSISTENT); | 1782 | MHD_RESPMEM_PERSISTENT); |
1782 | MHD_queue_response (connection, | 1783 | if (NULL == response) |
1783 | status_code, | 1784 | { |
1784 | response); | 1785 | /* can't even send a reply, at least close the connection */ |
1785 | mhd_assert (NULL != connection->response); | 1786 | connection->state = MHD_CONNECTION_CLOSED; |
1787 | return; | ||
1788 | } | ||
1789 | iret = MHD_queue_response (connection, | ||
1790 | status_code, | ||
1791 | response); | ||
1786 | MHD_destroy_response (response); | 1792 | MHD_destroy_response (response); |
1793 | if (MHD_YES != iret) | ||
1794 | { | ||
1795 | /* can't even send a reply, at least close the connection */ | ||
1796 | CONNECTION_CLOSE_ERROR (connection, | ||
1797 | _("Closing connection (failed to queue response)\n")); | ||
1798 | return; | ||
1799 | } | ||
1800 | mhd_assert (NULL != connection->response); | ||
1787 | /* Do not reuse this connection. */ | 1801 | /* Do not reuse this connection. */ |
1788 | connection->keepalive = MHD_CONN_MUST_CLOSE; | 1802 | connection->keepalive = MHD_CONN_MUST_CLOSE; |
1789 | if (MHD_NO == build_header_response (connection)) | 1803 | if (MHD_NO == build_header_response (connection)) |
@@ -2732,6 +2746,8 @@ parse_connection_headers (struct MHD_Connection *connection) | |||
2732 | MHD_HEADER_KIND, | 2746 | MHD_HEADER_KIND, |
2733 | MHD_HTTP_HEADER_HOST)) ) | 2747 | MHD_HTTP_HEADER_HOST)) ) |
2734 | { | 2748 | { |
2749 | int iret; | ||
2750 | |||
2735 | /* die, http 1.1 request without host and we are pedantic */ | 2751 | /* die, http 1.1 request without host and we are pedantic */ |
2736 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; | 2752 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; |
2737 | connection->read_closed = true; | 2753 | connection->read_closed = true; |
@@ -2744,10 +2760,23 @@ parse_connection_headers (struct MHD_Connection *connection) | |||
2744 | MHD_create_response_from_buffer (MHD_STATICSTR_LEN_ (REQUEST_LACKS_HOST), | 2760 | MHD_create_response_from_buffer (MHD_STATICSTR_LEN_ (REQUEST_LACKS_HOST), |
2745 | REQUEST_LACKS_HOST, | 2761 | REQUEST_LACKS_HOST, |
2746 | MHD_RESPMEM_PERSISTENT); | 2762 | MHD_RESPMEM_PERSISTENT); |
2747 | MHD_queue_response (connection, | 2763 | if (NULL == response) |
2748 | MHD_HTTP_BAD_REQUEST, | 2764 | { |
2749 | response); | 2765 | /* can't even send a reply, at least close the connection */ |
2766 | CONNECTION_CLOSE_ERROR (connection, | ||
2767 | _("Closing connection (failed to create response)\n")); | ||
2768 | return; | ||
2769 | } | ||
2770 | iret = MHD_queue_response (connection, | ||
2771 | MHD_HTTP_BAD_REQUEST, | ||
2772 | response); | ||
2750 | MHD_destroy_response (response); | 2773 | MHD_destroy_response (response); |
2774 | if (MHD_YES != iret) | ||
2775 | { | ||
2776 | /* can't even send a reply, at least close the connection */ | ||
2777 | CONNECTION_CLOSE_ERROR (connection, | ||
2778 | _("Closing connection (failed to queue response)\n")); | ||
2779 | } | ||
2751 | return; | 2780 | return; |
2752 | } | 2781 | } |
2753 | 2782 | ||
diff --git a/src/microhttpd/test_postprocessor.c b/src/microhttpd/test_postprocessor.c index 8edc5b22..36b32f6d 100644 --- a/src/microhttpd/test_postprocessor.c +++ b/src/microhttpd/test_postprocessor.c | |||
@@ -171,8 +171,6 @@ test_multipart_garbage (void) | |||
171 | xdata[1] = 'x'; | 171 | xdata[1] = 'x'; |
172 | xdata[2] = '\r'; | 172 | xdata[2] = '\r'; |
173 | memcpy (&xdata[3], FORM_DATA, size); | 173 | memcpy (&xdata[3], FORM_DATA, size); |
174 | |||
175 | size = strlen (FORM_DATA); | ||
176 | size += 3; | 174 | size += 3; |
177 | for (splitpoint = 1; splitpoint < size; splitpoint++) | 175 | for (splitpoint = 1; splitpoint < size; splitpoint++) |
178 | { | 176 | { |