]> granicus.if.org Git - procps-ng/commitdiff
0080-proc/readproc.c: Harden openproc().
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Sat, 9 Jun 2018 11:35:19 +0000 (21:35 +1000)
Replace xmalloc() with xcalloc().

---------------------------- adapted for newlib branch
. trade xcalloc() for calloc()
. thus we must account for potential ENOMEM

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/readproc.c

index 0b88242ada9c3d6d352b03f359d9f6e28ff810ac..61633612149aed88f9f98e0f8e18aa034f116758 100644 (file)
@@ -37,6 +37,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <limits.h>
+#include <stdint.h>
 #ifdef WITH_SYSTEMD
 #include <systemd/sd-login.h>
 #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;