[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 10/15: connection.c: fixed handling of various errors au
From: |
gnunet |
Subject: |
[libmicrohttpd] 10/15: connection.c: fixed handling of various errors automatically detected by MHD code |
Date: |
Fri, 28 Oct 2022 11:21:59 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit f1bfbe71dcb3c6d30c6d89e165deda6778d422d5
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Oct 23 12:01:39 2022 +0300
connection.c: fixed handling of various errors automatically detected by
MHD code
Make sure that errors replies are processed correctly.
---
src/microhttpd/connection.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index cc6192ad..798052da 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -4842,6 +4842,8 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
case MHD_CONNECTION_REQ_LINE_RECEIVING:
line = get_next_header_line (connection,
&line_len);
+ if (MHD_CONNECTION_REQ_LINE_RECEIVING < connection->state)
+ continue;
if (NULL != line)
{
/* Check for empty string, as we might want
@@ -4876,10 +4878,10 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
case MHD_CONNECTION_URL_RECEIVED:
line = get_next_header_line (connection,
NULL);
+ if (MHD_CONNECTION_URL_RECEIVED != connection->state)
+ continue;
if (NULL == line)
{
- if (MHD_CONNECTION_URL_RECEIVED != connection->state)
- continue;
if (connection->read_closed)
{
CONNECTION_CLOSE_ERROR (connection,
@@ -4908,6 +4910,8 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
case MHD_CONNECTION_HEADER_PART_RECEIVED:
line = get_next_header_line (connection,
NULL);
+ if (MHD_CONNECTION_HEADER_PART_RECEIVED != connection->state)
+ continue;
if (NULL == line)
{
if (connection->state != MHD_CONNECTION_HEADER_PART_RECEIVED)
@@ -4935,7 +4939,7 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
continue;
case MHD_CONNECTION_HEADERS_RECEIVED:
parse_connection_headers (connection);
- if (MHD_CONNECTION_CLOSED == connection->state)
+ if (MHD_CONNECTION_HEADERS_RECEIVED != connection->state)
continue;
connection->state = MHD_CONNECTION_HEADERS_PROCESSED;
if (connection->suspended)
@@ -4943,7 +4947,7 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
continue;
case MHD_CONNECTION_HEADERS_PROCESSED:
call_connection_handler (connection); /* first call */
- if (MHD_CONNECTION_CLOSED == connection->state)
+ if (MHD_CONNECTION_HEADERS_PROCESSED != connection->state)
continue;
if (connection->suspended)
continue;
@@ -4983,11 +4987,8 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
if (0 != connection->read_buffer_offset)
{
process_request_body (connection); /* loop call */
- if (connection->discard_request)
- {
- mhd_assert (MHD_CONNECTION_BODY_RECEIVING != connection->state);
+ if (MHD_CONNECTION_BODY_RECEIVING != connection->state)
continue;
- }
}
if ( (0 == connection->rq.remaining_upload_size) ||
( (MHD_SIZE_UNKNOWN == connection->rq.remaining_upload_size) &&
@@ -5007,10 +5008,10 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
case MHD_CONNECTION_BODY_RECEIVED:
line = get_next_header_line (connection,
NULL);
+ if (connection->state != MHD_CONNECTION_BODY_RECEIVED)
+ continue;
if (NULL == line)
{
- if (connection->state != MHD_CONNECTION_BODY_RECEIVED)
- continue;
if (connection->read_closed)
{
CONNECTION_CLOSE_ERROR (connection,
@@ -5041,10 +5042,10 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
case MHD_CONNECTION_FOOTER_PART_RECEIVED:
line = get_next_header_line (connection,
NULL);
+ if (connection->state != MHD_CONNECTION_FOOTER_PART_RECEIVED)
+ continue;
if (NULL == line)
{
- if (connection->state != MHD_CONNECTION_FOOTER_PART_RECEIVED)
- continue;
if (connection->read_closed)
{
CONNECTION_CLOSE_ERROR (connection,
@@ -5073,7 +5074,7 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
continue;
case MHD_CONNECTION_FULL_REQ_RECEIVED:
call_connection_handler (connection); /* "final" call */
- if (connection->state == MHD_CONNECTION_CLOSED)
+ if (connection->state != MHD_CONNECTION_FULL_REQ_RECEIVED)
continue;
if (NULL == connection->rp.response)
break; /* try again next time */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 12/15: test_head: added check for excess data in reply, (continued)
- [libmicrohttpd] 12/15: test_head: added check for excess data in reply, gnunet, 2022/10/28
- [libmicrohttpd] 04/15: Added new state for MHD_ConnectionEventLoopInfo, gnunet, 2022/10/28
- [libmicrohttpd] 14/15: postprocessor.h: fixed typos in doxy, gnunet, 2022/10/28
- [libmicrohttpd] 11/15: testcurl: added test with Content-Length broken value in request, gnunet, 2022/10/28
- [libmicrohttpd] 08/15: Do not send "100 Continue" if part of the request body is already received, gnunet, 2022/10/28
- [libmicrohttpd] 01/15: Added ability to check for MHD debug builds at run-time, gnunet, 2022/10/28
- [libmicrohttpd] 02/15: Added check for hypothetical too large accepted sockets addresses, gnunet, 2022/10/28
- [libmicrohttpd] 13/15: test_head: check libcurl for timeout value, gnunet, 2022/10/28
- [libmicrohttpd] 06/15: Renamed one more connection state for clarity, gnunet, 2022/10/28
- [libmicrohttpd] 05/15: Renamed one state in MHD_ConnectionEventLoopInfo for clarity, gnunet, 2022/10/28
- [libmicrohttpd] 10/15: connection.c: fixed handling of various errors automatically detected by MHD code,
gnunet <=
- [libmicrohttpd] 09/15: Reworked partial processing of the upload, gnunet, 2022/10/28
- [libmicrohttpd] 15/15: microhttpd.h: doxy improvements, gnunet, 2022/10/28
- [libmicrohttpd] 07/15: Do not send "100 Continue" if request does not have a body, gnunet, 2022/10/28