gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated: MHD_send_on_connection2_(): handl


From: gnunet
Subject: [libmicrohttpd] branch master updated: MHD_send_on_connection2_(): handle oversized
Date: Fri, 11 Dec 2020 19:40:34 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new 4ce620be MHD_send_on_connection2_(): handle oversized
4ce620be is described below

commit 4ce620be913b9f9817e2937883f92bd3217ce0b3
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Fri Dec 11 21:39:55 2020 +0300

    MHD_send_on_connection2_(): handle oversized
    
    Fixed handling of oversized buffers
---
 src/microhttpd/mhd_send.c | 47 ++++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 018ba657..85c6df93 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -22,7 +22,7 @@
 
 /**
  * @file microhttpd/mhd_send.c
- * @brief Implementation of send() wrappers.
+ * @brief Implementation of send() wrappers and helper functions.
  * @author Karlson2k (Evgeny Grin)
  * @author ng0 (N. Gillmann)
  * @author Christian Grothoff
@@ -831,30 +831,39 @@ MHD_send_on_connection2_ (struct MHD_Connection 
*connection,
                           const char *buffer,
                           size_t buffer_size)
 {
+#if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
   MHD_socket s = connection->socket_fd;
   ssize_t ret;
-#if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
   struct iovec vector[2];
-#endif /* HAVE_SENDMSG || HAVE_WRITEV */
 #ifdef HTTPS_SUPPORT
-  const bool tls_conn = (connection->daemon->options & MHD_USE_TLS);
+  const bool no_vec = (connection->daemon->options & MHD_USE_TLS);
 #else  /* ! HTTPS_SUPPORT */
-  const bool tls_conn = false;
+  const bool no_vec = false;
 #endif /* ! HTTPS_SUPPORT */
+#endif /* HAVE_SENDMSG || HAVE_WRITEV */
 
-#ifdef HTTPS_SUPPORT
-  if (tls_conn)
+  if (
+#if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
+    (no_vec) ||
+    (0 == buffer_size) ||
+    ((size_t) SSIZE_MAX <= header_size)
+#else  /* ! (HAVE_SENDMSG || HAVE_WRITEV) */
+    true
+#endif /* ! (HAVE_SENDMSG || HAVE_WRITEV) */
+    )
   {
-    ssize_t ret;
+    return MHD_send_on_connection_ (connection,
+                                    header,
+                                    header_size,
+                                    MHD_SSO_HDR_CORK);
 
-    ret = MHD_send_on_connection_ (connection,
-                                   header,
-                                   header_size,
-                                   MHD_SSO_HDR_CORK);
-    return ret;
   }
-#endif
 #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
+
+  if ( ((size_t) SSIZE_MAX <= buffer_size) ||
+       ((size_t) SSIZE_MAX < (header_size + buffer_size)) )
+    buffer_size = SSIZE_MAX - header_size;
+
   /* Since we generally give the fully answer, we do not want
      corking to happen */
   pre_send_setopt (connection,
@@ -912,13 +921,9 @@ MHD_send_on_connection2_ (struct MHD_Connection 
*connection,
                       true);
 
   return ret;
-
-#else
-  return MHD_send_on_connection_ (connection,
-                                  header,
-                                  header_size,
-                                  MHD_SSO_HDR_CORK);
-#endif
+#else  /* ! (HAVE_SENDMSG || HAVE_WRITEV) */
+  return 0; /* Unreachable. Mute warnings. */
+#endif /* ! (HAVE_SENDMSG || HAVE_WRITEV) */
 }
 
 

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