gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated: check response alloc


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated: check response allocation succeeded when generating internal errors
Date: Fri, 22 Jun 2018 15:58:35 +0200

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

grothoff pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new 9b4358cd check response allocation succeeded when generating internal 
errors
9b4358cd is described below

commit 9b4358cd5a46b7cd85663c09811ab8258662c158
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Jun 22 15:58:24 2018 +0200

    check response allocation succeeded when generating internal errors
---
 src/microhttpd/connection.c         | 43 +++++++++++++++++++++++++++++++------
 src/microhttpd/test_postprocessor.c |  2 --
 src/testzzuf/socat.c                |  1 -
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 13b5015b..1778c59b 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1756,6 +1756,7 @@ transmit_error_response (struct MHD_Connection 
*connection,
                         const char *message)
 {
   struct MHD_Response *response;
+  int iret;
 
   if (NULL == connection->version)
     {
@@ -1779,11 +1780,24 @@ transmit_error_response (struct MHD_Connection 
*connection,
   response = MHD_create_response_from_buffer (strlen (message),
                                              (void *) message,
                                              MHD_RESPMEM_PERSISTENT);
-  MHD_queue_response (connection,
-                      status_code,
-                      response);
-  mhd_assert (NULL != connection->response);
+  if (NULL == response)
+    {
+      /* can't even send a reply, at least close the connection */
+      connection->state = MHD_CONNECTION_CLOSED;
+      return;
+    }
+  iret = MHD_queue_response (connection,
+                             status_code,
+                             response);
   MHD_destroy_response (response);
+  if (MHD_YES != iret)
+    {
+      /* can't even send a reply, at least close the connection */
+      CONNECTION_CLOSE_ERROR (connection,
+                              _("Closing connection (failed to queue 
response)\n"));
+      return;
+    }
+  mhd_assert (NULL != connection->response);
   /* Do not reuse this connection. */
   connection->keepalive = MHD_CONN_MUST_CLOSE;
   if (MHD_NO == build_header_response (connection))
@@ -2732,6 +2746,8 @@ parse_connection_headers (struct MHD_Connection 
*connection)
                                      MHD_HEADER_KIND,
                                      MHD_HTTP_HEADER_HOST)) )
     {
+      int iret;
+
       /* die, http 1.1 request without host and we are pedantic */
       connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
       connection->read_closed = true;
@@ -2744,10 +2760,23 @@ parse_connection_headers (struct MHD_Connection 
*connection)
         MHD_create_response_from_buffer (MHD_STATICSTR_LEN_ 
(REQUEST_LACKS_HOST),
                                         REQUEST_LACKS_HOST,
                                         MHD_RESPMEM_PERSISTENT);
-      MHD_queue_response (connection,
-                          MHD_HTTP_BAD_REQUEST,
-                          response);
+      if (NULL == response)
+        {
+          /* can't even send a reply, at least close the connection */
+          CONNECTION_CLOSE_ERROR (connection,
+                                  _("Closing connection (failed to create 
response)\n"));
+          return;
+        }
+      iret = MHD_queue_response (connection,
+                                 MHD_HTTP_BAD_REQUEST,
+                                 response);
       MHD_destroy_response (response);
+      if (MHD_YES != iret)
+        {
+          /* can't even send a reply, at least close the connection */
+          CONNECTION_CLOSE_ERROR (connection,
+                                  _("Closing connection (failed to queue 
response)\n"));
+        }
       return;
     }
 
diff --git a/src/microhttpd/test_postprocessor.c 
b/src/microhttpd/test_postprocessor.c
index 8edc5b22..36b32f6d 100644
--- a/src/microhttpd/test_postprocessor.c
+++ b/src/microhttpd/test_postprocessor.c
@@ -171,8 +171,6 @@ test_multipart_garbage (void)
   xdata[1] = 'x';
   xdata[2] = '\r';
   memcpy (&xdata[3], FORM_DATA, size);
-
-  size = strlen (FORM_DATA);
   size += 3;
   for (splitpoint = 1; splitpoint < size; splitpoint++)
   {
diff --git a/src/testzzuf/socat.c b/src/testzzuf/socat.c
index b21f2c6f..72089a6d 100644
--- a/src/testzzuf/socat.c
+++ b/src/testzzuf/socat.c
@@ -91,7 +91,6 @@ zzuf_socat_start ()
   setpgid (0, 0);
   execvp ("zzuf", args);
   fprintf (stderr, "execution of `zzuf' failed: %s\n", strerror (errno));
-  zzuf_pid = 0;                 /* fork failed */
   exit (1);
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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