Hi!

I ran into gnunets services just segfaulting sometimes.

I ran into the behaviour when running the transport service with the
transport.conf from the (meson) build output. (with an additional PEER section for the private key).

I think I had similar segfaults with other services too, but don't feel like trying to reproduce those tbh.

Was the NULL check missing due to performance or something?

Kind regards
fence
From fe5757f56f2443e1bc95ad17ab376be781752877 Mon Sep 17 00:00:00 2001
From: fence <fe...@desu-mail.moe>
Date: Tue, 23 Jul 2024 15:33:50 +0200
Subject: [PATCH] util: fix segfaults when config lacks a section

I ran into the behaviour when running the transport service with the
transport.conf from the build output.
I think I had similar segfaults with other services too.
---
 src/lib/util/configuration.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/lib/util/configuration.c b/src/lib/util/configuration.c
index 17ba253ff..909a4e4a3 100644
--- a/src/lib/util/configuration.c
+++ b/src/lib/util/configuration.c
@@ -400,6 +400,9 @@ find_section (const struct GNUNET_CONFIGURATION_Handle *cfg,
 {
   struct ConfigSection *pos;
 
+  if (NULL == cfg)
+    return NULL;
+
   pos = cfg->sections;
   while ((pos != NULL) && (0 != strcasecmp (section, pos->name)))
     pos = pos->next;
-- 
2.39.3 (Apple Git-145)

Reply via email to