From 36e066df52eedf147a51e4cf3a86fd13748d6f79 Mon Sep 17 00:00:00 2001 From: Jan Rybar Date: Mon, 23 Jul 2018 14:44:52 +0200 Subject: [PATCH] Possible segfault in file2strvec introduced by latest CVE fix 'rbuf' used before allocated. Revealed by static analysis --- proc/readproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proc/readproc.c b/proc/readproc.c index a6666cbc..54459253 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -720,7 +720,7 @@ static char** file2strvec(const char* directory, const char* what) { #undef ARG_LEN if (end_of_file && ((n > 0 && buf[n-1] != '\0') || /* last read char not null */ - (n <= 0 && rbuf[tot-1] != '\0'))) /* last read char not null */ + (n <= 0 && rbuf && rbuf[tot-1] != '\0'))) /* last read char not null */ buf[n++] = '\0'; /* so append null-terminator */ if (n <= 0) break; /* unneeded (end_of_file = 1) but avoid realloc */