gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 04/04: MHD_ip_addr_to_key(): identify type of address by


From: gnunet
Subject: [libmicrohttpd] 04/04: MHD_ip_addr_to_key(): identify type of address by 'sa_family' instead of size
Date: Mon, 31 Jan 2022 13:49:04 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 03953a6960165607def5415bd4cfc72f76239fff
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Jan 31 15:48:30 2022 +0300

    MHD_ip_addr_to_key(): identify type of address by 'sa_family' instead of 
size
    
    Potentially size of some address family may match size of know address 
family.
---
 src/microhttpd/daemon.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 905844c7..47fe742d 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -330,9 +330,10 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
           sizeof(*key));
 
   /* IPv4 addresses */
-  if (sizeof (struct sockaddr_in) == addrlen)
+  if (AF_INET == addr->sa_family)
   {
     const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr;
+    mhd_assert (sizeof (struct sockaddr_in) <= addrlen);
 
     key->family = AF_INET;
     memcpy (&key->addr.ipv4,
@@ -343,9 +344,10 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
 
 #if HAVE_INET6
   /* IPv6 addresses */
-  if (sizeof (struct sockaddr_in6) == addrlen)
+  if (AF_INET6 == addr->sa_family)
   {
     const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *) addr;
+    mhd_assert (sizeof (struct sockaddr_in6) <= addrlen);
 
     key->family = AF_INET6;
     memcpy (&key->addr.ipv6,

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