gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 02/03: Unified bare LF as CRLF handling for request chun


From: gnunet
Subject: [libmicrohttpd] 02/03: Unified bare LF as CRLF handling for request chunked encoding
Date: Wed, 27 Sep 2023 18:45:10 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 21ffbbd37874a509340bb42d1d77cc7c677d8225
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Tue Sep 26 17:27:52 2023 +0300

    Unified bare LF as CRLF handling for request chunked encoding
---
 src/microhttpd/connection.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 104678fe..b15efb8a 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -4387,6 +4387,12 @@ process_request_body (struct MHD_Connection *connection)
   size_t available;
   bool instant_retry;
   char *buffer_head;
+  const int discp_lvl = daemon->client_discipline;
+  /* Treat bare LF as the end of the line.
+     RFC 9112, section 2.2-3
+     Note: MHD never replaces bare LF with space (RFC 9110, section 5.5-5).
+     Bare LF is processed as end of the line or rejected as broken request. */
+  const bool bare_lf_as_crlf = MHD_ALLOW_BARE_LF_AS_CRLF_ (discp_lvl);
 
   mhd_assert (NULL == connection->rp.response);
 
@@ -4414,7 +4420,7 @@ process_request_body (struct MHD_Connection *connection)
              ('\r' == buffer_head[0]) &&
              ('\n' == buffer_head[1]) )
           i += 2;                        /* skip CRLF */
-        else if ('\n' == buffer_head[0]) /* TODO: Add MHD option to disallow */
+        else if (bare_lf_as_crlf && ('\n' == buffer_head[0]))
           i++;                           /* skip bare LF */
         else if (2 > available)
           break;                         /* need more upload data */
@@ -4477,9 +4483,13 @@ process_request_body (struct MHD_Connection *connection)
             }
             else
             { /* bare LF */
-              /* TODO: Add an option to disallow bare LF */
-              if (! found_chunk_size_str)
-                chunk_size_len = i;
+              if (bare_lf_as_crlf)
+              {
+                if (! found_chunk_size_str)
+                  chunk_size_len = i;
+              }
+              else
+                chunk_size_len = 0; /* Malformed */
             }
             found_chunk_size_str = true;
             break; /* Found the end of the string */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]