From 990ea89ae91d9b6747db8e3b192adeebab31426f Mon Sep 17 00:00:00 2001 From: Qualys Security Advisory Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] 0080-proc/readproc.c: Harden openproc(). Replace xmalloc() with xcalloc(). ---------------------------- adapted for newlib branch . trade xcalloc() for calloc() . thus we must account for potential ENOMEM Signed-off-by: Jim Warner --- proc/readproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proc/readproc.c b/proc/readproc.c index 0b88242a..61633612 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -37,6 +37,7 @@ #include #include #include +#include #ifdef WITH_SYSTEMD #include #endif @@ -1369,7 +1370,7 @@ PROCTAB* openproc(unsigned flags, ...) { va_list ap; struct stat sbuf; static int did_stat; - PROCTAB* PT = malloc(sizeof(PROCTAB)); + PROCTAB* PT = calloc(1, sizeof(PROCTAB)); if (!PT) return NULL; -- 2.40.0