gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 04/05: connection.c: simplified request line processing,


From: gnunet
Subject: [libmicrohttpd] 04/05: connection.c: simplified request line processing, fix
Date: Sat, 21 Aug 2021 17:41:26 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 66e6f4f2e965682d1cabaf217d6db40beb0877e1
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Aug 21 18:28:35 2021 +0300

    connection.c: simplified request line processing, fix
    
    Fixed potential hung when the first line is empty and no
    other connections are processed.
---
 src/microhttpd/connection.c | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 7b61916f..2ee1ceb2 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -4104,34 +4104,32 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
     case MHD_CONNECTION_INIT:
       line = get_next_header_line (connection,
                                    &line_len);
-      /* Check for empty string, as we might want
-         to tolerate 'spurious' empty lines; also
-         NULL means we didn't get a full line yet;
-         line is not 0-terminated here. */
-      if ( (NULL == line) ||
-           (0 == line[0]) )
+      if (NULL != line)
       {
-        if (MHD_CONNECTION_INIT != connection->state)
-          continue;
-        if (connection->stop_with_error)
+        /* Check for empty string, as we might want
+           to tolerate 'spurious' empty lines */
+        if (0 == line[0])
+          /* TODO: Add MHD option to not tolerate it */
+          continue; /* Process the next line */
+        if (MHD_NO == parse_initial_message_line (connection,
+                                                  line,
+                                                  line_len))
+          CONNECTION_CLOSE_ERROR_CHECK (connection,
+                                        NULL);
+        else
         {
-          CONNECTION_CLOSE_ERROR (connection,
-                                  NULL);
-          continue;
+          mhd_assert (MHD_IS_HTTP_VER_SUPPORTED (connection->http_ver));
+          connection->state = MHD_CONNECTION_URL_RECEIVED;
         }
-        break;
+        continue;
       }
-      if (MHD_NO == parse_initial_message_line (connection,
-                                                line,
-                                                line_len))
-        CONNECTION_CLOSE_ERROR_CHECK (connection,
-                                      NULL);
-      else
+      /* NULL means we didn't get a full line yet */
+      if (connection->stop_with_error)
       {
-        mhd_assert (MHD_IS_HTTP_VER_SUPPORTED (connection->http_ver));
-        connection->state = MHD_CONNECTION_URL_RECEIVED;
+        mhd_assert (MHD_CONNECTION_INIT != connection->state);
+        continue;
       }
-      continue;
+      break;
     case MHD_CONNECTION_URL_RECEIVED:
       line = get_next_header_line (connection,
                                    NULL);

-- 
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]