View Issue Details

IDProjectCategoryView StatusLast Update
0008812GNUnettransport servicepublic2024-06-08 12:03
Reporterulfvonbelow Assigned Toschanzen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86-64OSGuix SystemOS Versiona1d711c92e
Product VersionGit master 
Fixed in Version0.21.2 
Summary0008812: memory leak in extract_address in tcp communicator
Descriptionres = GNUNET_strdup (token);
addr = GNUNET_strdup (res);

and then later on addr gets returned, while res is leaked. res is used nowhere else in the entire procedure.

Strange piece of code.
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 communicator-tcp to log to
Additional InformationPatch attached.
TagsNo tags attached.
Attached Files
0001-transport-fix-memory-leak-in-extract_address-in-tcp-.patch (1,041 bytes)   
From cea273582740ca85377d29f58c69856256b99756 Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Sun, 5 May 2024 01:51:36 -0500
Subject: [PATCH] transport: fix memory leak in extract_address in tcp
 communicator.

---
 src/service/transport/gnunet-communicator-tcp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/service/transport/gnunet-communicator-tcp.c b/src/service/transport/gnunet-communicator-tcp.c
index 02a547335..d13473b0a 100644
--- a/src/service/transport/gnunet-communicator-tcp.c
+++ b/src/service/transport/gnunet-communicator-tcp.c
@@ -2369,7 +2369,6 @@ extract_address (const char *bindto)
   char *token;
   char *cp;
   char *rest = NULL;
-  char *res;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "extract address with bindto %s\n",
@@ -2402,8 +2401,7 @@ extract_address (const char *bindto)
     else
     {
       token++;
-      res = GNUNET_strdup (token);
-      addr = GNUNET_strdup (res);
+      addr = GNUNET_strdup (token);
     }
   }
 
-- 
2.41.0

Activities

schanzen

2024-05-13 10:51

administrator   ~0022396

Applied

schanzen

2024-06-08 12:03

administrator   ~0022533

0.21.2 released

Issue History

Date Modified Username Field Change
2024-05-07 05:37 ulfvonbelow New Issue
2024-05-07 05:37 ulfvonbelow File Added: 0001-transport-fix-memory-leak-in-extract_address-in-tcp-.patch
2024-05-13 10:51 schanzen Assigned To => schanzen
2024-05-13 10:51 schanzen Status new => resolved
2024-05-13 10:51 schanzen Resolution open => fixed
2024-05-13 10:51 schanzen Fixed in Version => 0.21.2
2024-05-13 10:51 schanzen Note Added: 0022396
2024-06-08 12:03 schanzen Note Added: 0022533
2024-06-08 12:03 schanzen Status resolved => closed