[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated (f02888d4 -> 08fe527f)
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated (f02888d4 -> 08fe527f) |
Date: |
Mon, 03 Jul 2023 10:40:18 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a change to branch master
in repository libmicrohttpd.
from f02888d4 Focused all read-buffer grows in a single point, related
improvements.
new 02192349 Make sure that some space for request body is always available
new 08fe527f connection: fixed sending error responses
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/microhttpd/connection.c | 162 ++++++++++++++++++++++++++++++--------------
1 file changed, 113 insertions(+), 49 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 4d912ce8..bfe5b820 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -5062,11 +5062,14 @@ get_req_header (struct MHD_Connection *c,
}
else if (! bare_cr_keep)
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- BARE_CR_IN_HEADER :
- BARE_CR_IN_FOOTER);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ BARE_CR_IN_HEADER);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ BARE_CR_IN_FOOTER);
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */
}
end_of_line = false;
@@ -5088,10 +5091,14 @@ get_req_header (struct MHD_Connection *c,
}
else
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- BARE_LF_IN_HEADER : BARE_LF_IN_FOOTER);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ BARE_LF_IN_HEADER);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ BARE_LF_IN_FOOTER);
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */
}
}
@@ -5135,11 +5142,15 @@ get_req_header (struct MHD_Connection *c,
/* Folded line */
if (! allow_folded)
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- ERR_RSP_OBS_FOLD :
- ERR_RSP_OBS_FOLD_FOOTER);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_OBS_FOLD);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_OBS_FOLD_FOOTER);
+
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */
}
/* Replace CRLF (or bare LF) character(s) with space characters.
@@ -5171,11 +5182,15 @@ get_req_header (struct MHD_Connection *c,
{
if (! allow_line_without_colon)
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- ERR_RSP_HEADER_WITHOUT_COLON :
- ERR_RSP_FOOTER_WITHOUT_COLON);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_HEADER_WITHOUT_COLON);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_FOOTER_WITHOUT_COLON);
+
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */
}
/* Skip broken line completely */
@@ -5240,11 +5255,14 @@ get_req_header (struct MHD_Connection *c,
{
if (! allow_wsp_at_start)
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- ERR_RSP_WSP_BEFORE_HEADER :
- ERR_RSP_WSP_BEFORE_FOOTER);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_WSP_BEFORE_HEADER);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_WSP_BEFORE_FOOTER);
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */
}
c->rq.hdrs.hdr.starts_with_ws = true;
@@ -5260,11 +5278,15 @@ get_req_header (struct MHD_Connection *c,
}
else
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- ERR_RSP_WSP_IN_HEADER_NAME :
- ERR_RSP_WSP_IN_FOOTER_NAME);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_WSP_IN_HEADER_NAME);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_WSP_IN_FOOTER_NAME);
+
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */
}
}
@@ -5279,11 +5301,15 @@ get_req_header (struct MHD_Connection *c,
{
if (! nul_as_sp)
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- ERR_RSP_INVALID_CHR_IN_HEADER :
- ERR_RSP_INVALID_CHR_IN_FOOTER);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_INVALID_CHR_IN_HEADER);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_INVALID_CHR_IN_FOOTER);
+
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */
}
c->read_buffer[p] = ' ';
@@ -5308,11 +5334,14 @@ get_req_header (struct MHD_Connection *c,
mhd_assert (allow_wsp_in_name || allow_wsp_before_colon);
if (! allow_wsp_before_colon)
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- ERR_RSP_WSP_IN_HEADER_NAME :
- ERR_RSP_WSP_IN_FOOTER_NAME);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_WSP_IN_HEADER_NAME);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_WSP_IN_FOOTER_NAME);
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request
*/
}
c->rq.hdrs.hdr.name_len = c->rq.hdrs.hdr.ws_start;
@@ -5322,11 +5351,14 @@ get_req_header (struct MHD_Connection *c,
}
if ((0 == c->rq.hdrs.hdr.name_len) && ! allow_empty_name)
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- ERR_RSP_EMPTY_HEADER_NAME :
- ERR_RSP_EMPTY_FOOTER_NAME);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_EMPTY_HEADER_NAME);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_EMPTY_FOOTER_NAME);
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */
}
c->rq.hdrs.hdr.name_end_found = true;
@@ -5340,11 +5372,15 @@ get_req_header (struct MHD_Connection *c,
mhd_assert (allow_wsp_in_name || allow_wsp_before_colon);
if (! allow_wsp_in_name)
{
- transmit_error_response_static (c,
- MHD_HTTP_BAD_REQUEST,
- (! process_footers) ?
- ERR_RSP_WSP_IN_HEADER_NAME :
- ERR_RSP_WSP_IN_FOOTER_NAME);
+ if (! process_footers)
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_WSP_IN_HEADER_NAME);
+ else
+ transmit_error_response_static (c,
+ MHD_HTTP_BAD_REQUEST,
+ ERR_RSP_WSP_IN_FOOTER_NAME);
+
return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request
*/
}
#ifndef MHD_FAVOR_SMALL_CODE
@@ -5543,9 +5579,37 @@ get_req_headers (struct MHD_Connection *c, bool
process_footers)
{
c->rq.header_size = (size_t) (c->read_buffer - c->rq.method);
c->state = MHD_CONNECTION_HEADERS_RECEIVED;
+
+ if (MHD_BUF_INC_SIZE > c->read_buffer_size)
+ {
+ /* Try to re-use some of the last bytes of the request header */
+ /* Do this only if space in the read buffer is limited AND
+ amount of read ahead data is small. */
+ /**
+ * The position of the terminating NUL after the last character of
+ * the last header element.
+ */
+ const char *last_elmnt_end;
+ size_t shift_back_size;
+ if (NULL != c->rq.headers_received_tail)
+ last_elmnt_end =
+ c->rq.headers_received_tail->value
+ + c->rq.headers_received_tail->value_size;
+ else
+ last_elmnt_end = c->rq.version + HTTP_VER_LEN;
+ mhd_assert ((last_elmnt_end + 1) < c->read_buffer);
+ shift_back_size = (size_t) (c->read_buffer - (last_elmnt_end + 1));
+ if (0 != c->read_buffer_offset)
+ memmove (c->read_buffer - shift_back_size,
+ c->read_buffer,
+ c->read_buffer_offset);
+ c->read_buffer -= shift_back_size;
+ c->read_buffer_size += shift_back_size;
+ }
}
else
c->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+
return true;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (f02888d4 -> 08fe527f),
gnunet <=