View Issue Details

IDProjectCategoryView StatusLast Update
0007651GNUnetDHT servicepublic2024-06-08 12:03
Reporterulfvonbelow Assigned Toschanzen  
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionfixed 
Product VersionGit master 
Target Version0.19.4Fixed in Version0.21.2 
Summary0007651: "Memory leak" in gnunet-dht-get and gnunet-dht-put
DescriptionThe argv created by GNUNET_STRINGS_get_utf8_args is never freed.
Steps To Reproduce./configure --enable-sanitizer
make
make install
make check
Additional InformationNot a real problem, again, but sanitizers...
Patch attached.
Tagspatch
Attached Files
0001-DHT-remove-memory-leak-in-gnunet-dht-get-put.patch (2,234 bytes)   
From 5ecf4d9a574395b7a2c62623f658bcc043eca28f Mon Sep 17 00:00:00 2001
From: ulfvonbelow <strilen@tilde.club>
Date: Sun, 29 Jan 2023 07:08:37 -0600
Subject: [PATCH] DHT: remove "memory leak" in gnunet-dht-{get,put}.

Not really a memory leak, but good to get the sanitizers off our back.
---
 src/dht/gnunet-dht-get.c | 26 ++++++++++++++------------
 src/dht/gnunet-dht-put.c |  9 +++++----
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c
index 1ae9235f8..4a071dbad 100644
--- a/src/dht/gnunet-dht-get.c
+++ b/src/dht/gnunet-dht-get.c
@@ -329,18 +329,20 @@ main (int argc, char *const *argv)
       GNUNET_STRINGS_get_utf8_args (argc, argv,
                                     &argc, &argv))
     return 2;
-  return (GNUNET_OK ==
-          GNUNET_PROGRAM_run (
-            argc,
-            argv,
-            "gnunet-dht-get",
-            gettext_noop (
-              "Issue a GET request to the GNUnet DHT, prints results."),
-            options,
-            &run,
-            NULL))
-         ? ret
-         : 1;
+  ret = (GNUNET_OK ==
+         GNUNET_PROGRAM_run (
+           argc,
+           argv,
+           "gnunet-dht-get",
+           gettext_noop (
+             "Issue a GET request to the GNUnet DHT, prints results."),
+           options,
+           &run,
+           NULL))
+        ? ret
+        : 1;
+  GNUNET_free (argv);
+  return ret;
 }
 
 
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c
index 531107ef2..2281ff56b 100644
--- a/src/dht/gnunet-dht-put.c
+++ b/src/dht/gnunet-dht-put.c
@@ -226,13 +226,12 @@ main (int argc, char *const *argv)
     GNUNET_GETOPT_OPTION_END
   };
 
-
   if (GNUNET_OK !=
       GNUNET_STRINGS_get_utf8_args (argc, argv,
                                     &argc, &argv))
     return 2;
   expiration = GNUNET_TIME_UNIT_HOURS;
-  return (GNUNET_OK ==
+  ret = (GNUNET_OK ==
           GNUNET_PROGRAM_run (
             argc,
             argv,
@@ -242,8 +241,10 @@ main (int argc, char *const *argv)
             options,
             &run,
             NULL))
-         ? ret
-         : 1;
+        ? ret
+        : 1;
+  GNUNET_free (argv);
+  return ret;
 }
 
 
-- 
2.38.1

Activities

schanzen

2023-02-06 06:54

administrator   ~0019765

Actually, reverting this as we cannot free a const pointer here. This may have to be fixed in PROGRAM_run...

schanzen

2023-02-06 07:05

administrator   ~0019766

ab66a7a9d..eabc1baaf

ulfvonbelow

2023-05-25 18:51

reporter   ~0020201

eabc1baaf980d8948f3fc0ac83a84446d5f1b226 didn't reintroduce the 'ret = ...' line to replace the 'return ...' line, so it still always returns before the memory is freed. So the sanitizers still fail on this.

schanzen

2023-06-01 20:21

administrator   ~0020211

Fix committed to master branch.

schanzen

2023-06-01 20:26

administrator   ~0020212

released some time ago

ulfvonbelow

2024-05-03 03:49

reporter   ~0022331

The fix seems to have made its way only to gnunet-dht-get, not gnunet-dht-put

schanzen

2024-05-05 14:04

administrator   ~0022343

95f0616e0ca40eb2eef5881b0eaccc110a27fddc

schanzen

2024-05-05 14:04

administrator   ~0022344

Fix committed to master branch.

schanzen

2024-06-08 12:03

administrator   ~0022556

0.21.2 released

Related Changesets

gnunet: master f52d578f

2023-06-01 22:21

schanzen


Details Diff
DHT: Fix memory leak. Fixes 0007651 Affected Issues
0007651
mod - src/dht/gnunet-dht-get.c Diff File

gnunet: master 95f0616e

2024-05-05 16:03

schanzen


Details Diff
DHT: Fix memory lead in gnunet-dht-put. Fixes 0007651 Affected Issues
0007651
mod - src/cli/dht/gnunet-dht-put.c Diff File

Issue History

Date Modified Username Field Change
2023-01-30 00:49 ulfvonbelow New Issue
2023-01-30 00:49 ulfvonbelow Tag Attached: patch
2023-01-30 00:49 ulfvonbelow File Added: 0001-DHT-remove-memory-leak-in-gnunet-dht-get-put.patch
2023-02-06 05:53 schanzen Assigned To => schanzen
2023-02-06 05:53 schanzen Status new => resolved
2023-02-06 05:53 schanzen Resolution open => fixed
2023-02-06 05:53 schanzen Fixed in Version => 0.19.4
2023-02-06 06:19 schanzen Target Version => 0.19.4
2023-02-06 06:54 schanzen Status resolved => feedback
2023-02-06 06:54 schanzen Resolution fixed => reopened
2023-02-06 06:54 schanzen Note Added: 0019765
2023-02-06 07:05 schanzen Status feedback => resolved
2023-02-06 07:05 schanzen Resolution reopened => fixed
2023-02-06 07:05 schanzen Note Added: 0019766
2023-05-25 18:51 ulfvonbelow Status resolved => feedback
2023-05-25 18:51 ulfvonbelow Resolution fixed => reopened
2023-05-25 18:51 ulfvonbelow Note Added: 0020201
2023-06-01 20:21 schanzen Changeset attached => gnunet master f52d578f
2023-06-01 20:21 schanzen Note Added: 0020211
2023-06-01 20:21 schanzen Status feedback => resolved
2023-06-01 20:21 schanzen Resolution reopened => fixed
2023-06-01 20:26 schanzen Note Added: 0020212
2023-06-01 20:26 schanzen Status resolved => closed
2024-05-03 03:49 ulfvonbelow Status closed => feedback
2024-05-03 03:49 ulfvonbelow Resolution fixed => reopened
2024-05-03 03:49 ulfvonbelow Note Added: 0022331
2024-05-05 14:04 schanzen Status feedback => resolved
2024-05-05 14:04 schanzen Fixed in Version 0.19.4 => 0.21.2
2024-05-05 14:04 schanzen Note Added: 0022343
2024-05-05 14:04 schanzen Changeset attached => gnunet master 95f0616e
2024-05-05 14:04 schanzen Note Added: 0022344
2024-05-05 14:04 schanzen Resolution reopened => fixed
2024-06-08 12:03 schanzen Note Added: 0022556
2024-06-08 12:03 schanzen Status resolved => closed