gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (1e82d322 -> 02634d01)


From: gnunet
Subject: [libmicrohttpd] branch master updated (1e82d322 -> 02634d01)
Date: Mon, 31 Jan 2022 16:34:43 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 1e82d322 test_digestauth_concurrent: fixed non-W32 random generation
     new 464d1741 MHD_ip_limit_add(): do not use syscalls while holding the lock
     new 02634d01 daemon: fixed new compiler warnings

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/daemon.c | 52 +++++++++++++++++++++++++------------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 47fe742d..72ba708a 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -333,7 +333,7 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
   if (AF_INET == addr->sa_family)
   {
     const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr;
-    mhd_assert (sizeof (struct sockaddr_in) <= addrlen);
+    mhd_assert (sizeof (struct sockaddr_in) <= (size_t) addrlen);
 
     key->family = AF_INET;
     memcpy (&key->addr.ipv4,
@@ -347,7 +347,7 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
   if (AF_INET6 == addr->sa_family)
   {
     const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *) addr;
-    mhd_assert (sizeof (struct sockaddr_in6) <= addrlen);
+    mhd_assert (sizeof (struct sockaddr_in6) <= (size_t) addrlen);
 
     key->family = AF_INET6;
     memcpy (&key->addr.ipv6,
@@ -378,9 +378,9 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon,
                   const struct sockaddr *addr,
                   socklen_t addrlen)
 {
-  struct MHD_IPCount *key;
-  void **nodep;
-  void *node;
+  struct MHD_IPCount *newkeyp;
+  struct MHD_IPCount *keyp;
+  struct MHD_IPCount **nodep;
   enum MHD_Result result;
 
   daemon = MHD_get_master (daemon);
@@ -388,45 +388,47 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon,
   if (0 == daemon->per_ip_connection_limit)
     return MHD_YES;
 
-  if (NULL == (key = malloc (sizeof(*key))))
+  newkeyp = (struct MHD_IPCount *) malloc (sizeof(struct MHD_IPCount));
+  if (NULL == newkeyp)
     return MHD_NO;
 
   /* Initialize key */
   if (MHD_NO == MHD_ip_addr_to_key (addr,
                                     addrlen,
-                                    key))
+                                    newkeyp))
   {
-    /* Allow unhandled address types through */
-    free (key);
-    return MHD_YES;
+    free (newkeyp);
+    return MHD_YES; /* Allow unhandled address types through */
   }
+
   MHD_ip_count_lock (daemon);
 
   /* Search for the IP address */
-  if (NULL == (nodep = tsearch (key,
-                                &daemon->per_ip_connection_count,
-                                &MHD_ip_addr_compare)))
+  nodep = (struct MHD_IPCount **) tsearch (newkeyp,
+                                           &daemon->per_ip_connection_count,
+                                           &MHD_ip_addr_compare);
+  if (NULL == nodep)
   {
+    MHD_ip_count_unlock (daemon);
+    free (newkeyp);
 #ifdef HAVE_MESSAGES
     MHD_DLOG (daemon,
               _ ("Failed to add IP connection count node.\n"));
 #endif
-    MHD_ip_count_unlock (daemon);
-    free (key);
     return MHD_NO;
   }
-  node = *nodep;
-  /* If we got an existing node back, free the one we created */
-  if (node != key)
-    free (key);
-  key = (struct MHD_IPCount *) node;
+  keyp = *nodep;
   /* Test if there is room for another connection; if so,
    * increment count */
-  result = (key->count < daemon->per_ip_connection_limit) ? MHD_YES : MHD_NO;
+  result = (keyp->count < daemon->per_ip_connection_limit) ? MHD_YES : MHD_NO;
   if (MHD_NO != result)
-    ++key->count;
-
+    ++keyp->count;
   MHD_ip_count_unlock (daemon);
+
+  /* If we got an existing node back, free the one we created */
+  if (keyp != newkeyp)
+    free (newkeyp);
+
   return result;
 }
 
@@ -3435,7 +3437,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
   {
     if (AF_INET == addr->sa_family)
     {
-      if (sizeof(struct sockaddr_in) > addrlen)
+      if (sizeof(struct sockaddr_in) > (size_t) addrlen)
       {
 #ifdef HAVE_MESSAGES
         MHD_DLOG (daemon,
@@ -3448,7 +3450,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
 #ifdef HAVE_INET6
     if (AF_INET6 == addr->sa_family)
     {
-      if (sizeof(struct sockaddr_in6) > addrlen)
+      if (sizeof(struct sockaddr_in6) > (size_t) addrlen)
       {
 #ifdef HAVE_MESSAGES
         MHD_DLOG (daemon,

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