View Issue Details

IDProjectCategoryView StatusLast Update
0008822GNUnettransport servicepublic2024-06-08 12:03
Reporterulfvonbelow Assigned Toschanzen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86-64OSGuix SystemOS Versiona1d711c92e
Product VersionGit master 
Fixed in Version0.21.2 
Summary0008822: two more memory leaks in gnunet-service-transport
Descriptionhandle_add_address seems to act as though create_address_entry will take ownership of the memory it is passed, when in reality it just copies it. Consequently it is subsequently leaked.
Separately, iterate_address_and_compare_cb assigns address_uri_without_port to the result of calling get_address_without_port twice in a row. Naturally, the first result is leaked.
Steps To Reproduce1. Build gnunet with --enable-sanitizer
2. Start the node with gnunet-arm -s
3. Stop the node after a bit with gnunet-arm -e
4. Observe reported memory leak wherever you've configured transport to log to
Additional InformationPatch attached.

For future reference, is it better to group bugs together like this, or is one report per bug preferred?
TagsNo tags attached.
Attached Files
0001-TRANSPORT-fix-two-memory-leaks-in-transport-service.patch (1,722 bytes)   
From ea1df0d139e0984159bc1e480f2a34fbc7fc1af0 Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Mon, 6 May 2024 21:36:54 -0500
Subject: [PATCH] TRANSPORT: fix two memory leaks in transport service.

---
 src/service/transport/gnunet-service-transport.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/service/transport/gnunet-service-transport.c b/src/service/transport/gnunet-service-transport.c
index 8649b5493..40801acd8 100644
--- a/src/service/transport/gnunet-service-transport.c
+++ b/src/service/transport/gnunet-service-transport.c
@@ -5955,12 +5955,10 @@ handle_add_address (void *cls,
               "Communicator added address `%s'!\n",
               (const char *) &aam[1]);
   slen = ntohs (aam->header.size) - sizeof(*aam);
-  address = GNUNET_malloc (slen);
-  memcpy (address, &aam[1], slen);
   ale = create_address_entry (tc,
                         GNUNET_TIME_relative_ntoh (aam->expiration),
                         (enum GNUNET_NetworkType) ntohl (aam->nt),
-                        address,
+                        &aam[1],
                         aam->aid,
                         slen);
   GNUNET_CONTAINER_DLL_insert (tc->details.communicator.addr_head,
@@ -11610,10 +11608,10 @@ iterate_address_and_compare_cb (void *cls,
   char *address_uri;
   char *prefix;
   char *uri_without_port;
-  char *address_uri_without_port = get_address_without_port (queue->address); 
+  char *address_uri_without_port;
 
   slash = strrchr (uri, '/');
-  prefix = GNUNET_strndup (uri, (slash - uri) - 2); 
+  prefix = GNUNET_strndup (uri, (slash - uri) - 2);
   GNUNET_assert (NULL != slash);
   slash++;
   GNUNET_asprintf (&address_uri,
-- 
2.41.0

Activities

schanzen

2024-05-13 10:34

administrator   ~0022382

Fixed

schanzen

2024-06-08 12:03

administrator   ~0022545

0.21.2 released

Issue History

Date Modified Username Field Change
2024-05-07 07:21 ulfvonbelow New Issue
2024-05-07 07:21 ulfvonbelow File Added: 0001-TRANSPORT-fix-two-memory-leaks-in-transport-service.patch
2024-05-13 10:34 schanzen Assigned To => schanzen
2024-05-13 10:34 schanzen Status new => resolved
2024-05-13 10:34 schanzen Resolution open => fixed
2024-05-13 10:34 schanzen Fixed in Version => 0.21.2
2024-05-13 10:34 schanzen Note Added: 0022382
2024-06-08 12:03 schanzen Note Added: 0022545
2024-06-08 12:03 schanzen Status resolved => closed