From 6d87e29bef2d2cd3c40e49b9120fae5148030381 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 15 Feb 2022 20:23:49 +0100 Subject: ipcpd: Fix free in fail path of readdir The free of the buffer in the failure path of the readdir RIB functions was taking the wrong pointer in a couple of places. The FRCT RIB readdir was missing error handling for malloc and strdup. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/frct.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/lib/frct.c') diff --git a/src/lib/frct.c b/src/lib/frct.c index a1e792af..ff938aec 100644 --- a/src/lib/frct.c +++ b/src/lib/frct.c @@ -156,10 +156,19 @@ static int frct_rib_read(const char * path, static int frct_rib_readdir(char *** buf) { *buf = malloc(sizeof(**buf)); + if (*buf == NULL) + goto fail_malloc; (*buf)[0] = strdup("frct"); + if ((*buf)[0] == NULL) + goto fail_strdup; return 1; + + fail_strdup: + free(*buf); + fail_malloc: + return -ENOMEM; } static int frct_rib_getattr(const char * path, -- cgit v1.2.3