View Issue Details

IDProjectCategoryView StatusLast Update
0008795GNUnetGNSpublic2024-05-05 14:17
Reporterulfvonbelow Assigned Toschanzen  
PrioritynormalSeveritytrivialReproducibilityalways
Status resolvedResolutionfixed 
Platformx86-64OSGuix SystemOS Versiona1d711c92e
Product Version0.21.1 
Fixed in Version0.21.2 
Summary0008795: memory leak in test_gnsrecord_testvectors
Descriptionrrblock is never freed
Steps To Reproduce1. ./configure --enable-sanitizer ; make ; make check
2. Observe memory leak reported in test_gnsrecord_testvectors
Additional InformationPatch attached. With this plus the other recent patches, the test suite now passes with sanitizers enabled once again (provided that test_namestore_api_edit_records_sqlite is disabled and LSAN_OPTIONS=suppressions=$PWD/suppressions.txt where suppressions.txt contains "leak:test_cadet.c")

at least it was a much smaller patchset this time
TagsNo tags attached.
Attached Files
0001-gnsrecord-fix-memory-leak-in-test_gnsrecord_testvect.patch (1,821 bytes)   
From 7b925b8ce71a7f1d7ea7e7aafc14abf2d590af22 Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Thu, 2 May 2024 21:51:09 -0500
Subject: [PATCH] gnsrecord: fix memory leak in test_gnsrecord_testvectors

---
 src/lib/gnsrecord/test_gnsrecord_testvectors.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/lib/gnsrecord/test_gnsrecord_testvectors.c b/src/lib/gnsrecord/test_gnsrecord_testvectors.c
index 21a7a83b0..12b9efe56 100644
--- a/src/lib/gnsrecord/test_gnsrecord_testvectors.c
+++ b/src/lib/gnsrecord/test_gnsrecord_testvectors.c
@@ -655,6 +655,7 @@ main ()
       printf ("FAIL: query does not match:");
       printf ("  expected: %s", GNUNET_h2s (&expected_query));
       printf (", was: %s\n", GNUNET_h2s (&query));
+      GNUNET_free (rrblock);
       res = 1;
       break;
     }
@@ -671,6 +672,7 @@ main ()
     {
       printf ("FAIL: Deserialization of RDATA failed\n");
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     expire = GNUNET_GNSRECORD_record_get_expiration_time (
@@ -681,6 +683,7 @@ main ()
         (GNUNET_OK != check_derivations_pkey (label, expire, &pub, &tvs[i])))
     {
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     else if ((GNUNET_GNSRECORD_TYPE_EDKEY == ntohl (pub.type)) &&
@@ -688,6 +691,7 @@ main ()
                                                     &tvs[i])))
     {
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     if (GNUNET_OK != GNUNET_GNSRECORD_block_decrypt (rrblock,
@@ -698,10 +702,14 @@ main ()
     {
       printf ("FAIL: Decryption of RRBLOCK failed\n");
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     if (0 != res)
+    {
+      GNUNET_free (rrblock);
       break;
+    }
     printf ("Good.\n");
   }
   return res;
-- 
2.41.0

Activities

ulfvonbelow

2024-05-03 06:20

reporter   ~0022332

ah, the previous patch didn't include the GNUNET_free in the normal looping case... revised patch attached
0001-gnsrecord-fix-memory-leak-in-test_gnsrecord_testvect-2.patch (1,850 bytes)   
From 029f91509a172ea4d50259451044c48e453192ae Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Thu, 2 May 2024 21:51:09 -0500
Subject: [PATCH] gnsrecord: fix memory leak in test_gnsrecord_testvectors

---
 src/lib/gnsrecord/test_gnsrecord_testvectors.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/lib/gnsrecord/test_gnsrecord_testvectors.c b/src/lib/gnsrecord/test_gnsrecord_testvectors.c
index 21a7a83b0..4b171b165 100644
--- a/src/lib/gnsrecord/test_gnsrecord_testvectors.c
+++ b/src/lib/gnsrecord/test_gnsrecord_testvectors.c
@@ -655,6 +655,7 @@ main ()
       printf ("FAIL: query does not match:");
       printf ("  expected: %s", GNUNET_h2s (&expected_query));
       printf (", was: %s\n", GNUNET_h2s (&query));
+      GNUNET_free (rrblock);
       res = 1;
       break;
     }
@@ -671,6 +672,7 @@ main ()
     {
       printf ("FAIL: Deserialization of RDATA failed\n");
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     expire = GNUNET_GNSRECORD_record_get_expiration_time (
@@ -681,6 +683,7 @@ main ()
         (GNUNET_OK != check_derivations_pkey (label, expire, &pub, &tvs[i])))
     {
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     else if ((GNUNET_GNSRECORD_TYPE_EDKEY == ntohl (pub.type)) &&
@@ -688,6 +691,7 @@ main ()
                                                     &tvs[i])))
     {
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     if (GNUNET_OK != GNUNET_GNSRECORD_block_decrypt (rrblock,
@@ -698,10 +702,15 @@ main ()
     {
       printf ("FAIL: Decryption of RRBLOCK failed\n");
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     if (0 != res)
+    {
+      GNUNET_free (rrblock);
       break;
+    }
+    GNUNET_free (rrblock);
     printf ("Good.\n");
   }
   return res;
-- 
2.41.0

schanzen

2024-05-05 14:17

administrator   ~0022350

applied.

Issue History

Date Modified Username Field Change
2024-05-03 05:49 ulfvonbelow New Issue
2024-05-03 05:49 ulfvonbelow File Added: 0001-gnsrecord-fix-memory-leak-in-test_gnsrecord_testvect.patch
2024-05-03 06:20 ulfvonbelow Note Added: 0022332
2024-05-03 06:20 ulfvonbelow File Added: 0001-gnsrecord-fix-memory-leak-in-test_gnsrecord_testvect-2.patch
2024-05-05 14:17 schanzen Assigned To => schanzen
2024-05-05 14:17 schanzen Status new => resolved
2024-05-05 14:17 schanzen Resolution open => fixed
2024-05-05 14:17 schanzen Fixed in Version => 0.21.2
2024-05-05 14:17 schanzen Note Added: 0022350