diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-10-17 13:51:51 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-10-17 13:51:51 +0300 |
commit | 21cdab14f8c314dc44a90e3207fba7f4fc3f838c (patch) | |
tree | a36aa86a5315779d7eed12df0d14f5f71892edbb | |
parent | cb2d42d0afb29e7682c6d12cdbf7c731f4118c6f (diff) | |
download | libmicrohttpd-21cdab14f8c314dc44a90e3207fba7f4fc3f838c.tar.gz libmicrohttpd-21cdab14f8c314dc44a90e3207fba7f4fc3f838c.zip |
Transmit error reply to the clients if received broken chunked encoding
-rw-r--r-- | src/microhttpd/connection.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index da3fc1df..62e21d03 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -104,6 +104,17 @@ | |||
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * Response text used when the request HTTP chunked encoding is | ||
108 | * malformed. | ||
109 | */ | ||
110 | #ifdef HAVE_MESSAGES | ||
111 | #define REQUEST_CHUNKED_MALFORMED \ | ||
112 | "<html><head><title>Request malformed</title></head><body>Your HTTP chunked encoding was syntactically incorrect.</body></html>" | ||
113 | #else | ||
114 | #define REQUEST_CHUNKED_MALFORMED "" | ||
115 | #endif | ||
116 | |||
117 | /** | ||
107 | * Response text used when there is an internal server error. | 118 | * Response text used when there is an internal server error. |
108 | * | 119 | * |
109 | * Intentionally empty here to keep our memory footprint | 120 | * Intentionally empty here to keep our memory footprint |
@@ -3070,10 +3081,9 @@ process_request_body (struct MHD_Connection *connection) | |||
3070 | if (0 == i) | 3081 | if (0 == i) |
3071 | { | 3082 | { |
3072 | /* malformed encoding */ | 3083 | /* malformed encoding */ |
3073 | CONNECTION_CLOSE_ERROR (connection, | 3084 | transmit_error_response_static (connection, |
3074 | _ ("Received malformed HTTP request " \ | 3085 | MHD_HTTP_BAD_REQUEST, |
3075 | "(bad chunked encoding). " \ | 3086 | REQUEST_CHUNKED_MALFORMED); |
3076 | "Closing connection.")); | ||
3077 | return; | 3087 | return; |
3078 | } | 3088 | } |
3079 | available -= i; | 3089 | available -= i; |
@@ -3150,10 +3160,9 @@ process_request_body (struct MHD_Connection *connection) | |||
3150 | if (malformed) | 3160 | if (malformed) |
3151 | { | 3161 | { |
3152 | /* malformed encoding */ | 3162 | /* malformed encoding */ |
3153 | CONNECTION_CLOSE_ERROR (connection, | 3163 | transmit_error_response_static (connection, |
3154 | _ ("Received malformed HTTP request " \ | 3164 | MHD_HTTP_BAD_REQUEST, |
3155 | "(bad chunked encoding). " \ | 3165 | REQUEST_CHUNKED_MALFORMED); |
3156 | "Closing connection.")); | ||
3157 | return; | 3166 | return; |
3158 | } | 3167 | } |
3159 | /* skip 2nd part of line feed */ | 3168 | /* skip 2nd part of line feed */ |
@@ -4383,7 +4392,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
4383 | if (0 != connection->read_buffer_offset) | 4392 | if (0 != connection->read_buffer_offset) |
4384 | { | 4393 | { |
4385 | process_request_body (connection); /* loop call */ | 4394 | process_request_body (connection); /* loop call */ |
4386 | if (MHD_CONNECTION_CLOSED == connection->state) | 4395 | if (connection->stop_with_error) |
4387 | continue; | 4396 | continue; |
4388 | } | 4397 | } |
4389 | if ( (0 == connection->remaining_upload_size) || | 4398 | if ( (0 == connection->remaining_upload_size) || |