summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast/routing
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2025-08-11 06:26:54 +0200
committerSander Vrijders <sander@ouroboros.rocks>2025-08-11 10:17:14 +0200
commit1c9f509cdaf0233ae4848c05c8bcd0de98bde89a (patch)
treea4dcbc671f7e76e04824c460b9a9649b1753abbe /src/ipcpd/unicast/routing
parent5c9328203b277fc36550ba06720dd13e5940121b (diff)
downloadouroboros-1c9f509cdaf0233ae4848c05c8bcd0de98bde89a.tar.gz
ouroboros-1c9f509cdaf0233ae4848c05c8bcd0de98bde89a.zip
ipcpd: Fix readdir() not initializing ptrbe
Some IPCP (sub)components returned successfully with 0 entries but did not initialize the buf ptr when the RIB has no entries, causing a SEGV on free() in the RIB. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/unicast/routing')
-rw-r--r--src/ipcpd/unicast/routing/link-state.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ipcpd/unicast/routing/link-state.c b/src/ipcpd/unicast/routing/link-state.c
index 31b5a112..8021fc7d 100644
--- a/src/ipcpd/unicast/routing/link-state.c
+++ b/src/ipcpd/unicast/routing/link-state.c
@@ -262,12 +262,15 @@ static int lsdb_rib_readdir(char *** buf)
char entry[RIB_PATH_LEN + 1];
ssize_t idx = 0;
- assert(buf);
+ assert(buf != NULL);
pthread_rwlock_rdlock(&ls.db_lock);
- if (ls.db_len + ls.nbs_len == 0)
+ if (ls.db_len + ls.nbs_len == 0) {
+ *buf = NULL;
goto no_entries;
+ }
+
*buf = malloc(sizeof(**buf) * (ls.db_len + ls.nbs_len));
if (*buf == NULL)