From 97d4bf150046264ae8ae6f523e24d19860580346 Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Sun, 5 May 2024 23:45:29 -0500
Subject: [PATCH] TRANSPORT: fix contains_address.

GNUNET_memcmp takes two typed pointers and compares the bytes of the objects
pointed to, using the size of the type of the first argument. The first
argument here is of type char *, so it compares the character it points to to
the character the second argument points to. This is probably not what was
intended.
---
 src/service/transport/gnunet-service-transport.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/service/transport/gnunet-service-transport.c b/src/service/transport/gnunet-service-transport.c
index 38371032e..06c33ad00 100644
--- a/src/service/transport/gnunet-service-transport.c
+++ b/src/service/transport/gnunet-service-transport.c
@@ -11683,7 +11683,8 @@ contains_address (void *cls,
   struct TransportGlobalNattedAddress *tgna = value;
   char *addr = (char *) &tgna[1];
 
-  if (0 == GNUNET_memcmp (addr, tgna_cls->addr))
+  if (strlen(tgna_cls->addr) == tgna->address_length
+      && 0 == strncmp (addr, tgna_cls->addr, tgna->address_length))
   {
     tgna_cls->tgna = tgna;
     return GNUNET_NO;
-- 
2.41.0

