From d43be3861b1732b80e834294c4cb6cdb86365e91 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 18 Jan 2017 22:06:28 +0100 Subject: [PATCH] libc: fix potential nil dereference in system() posix wrapper Should also fix CID 155750. --- sys/src/lib/c/apw/system.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/src/lib/c/apw/system.c b/sys/src/lib/c/apw/system.c index 4cf5293..a6b8e7c 100644 --- a/sys/src/lib/c/apw/system.c +++ b/sys/src/lib/c/apw/system.c @@ -37,6 +37,8 @@ system(const char *command) // TODO: fix this http://man7.org/linux/man-pages/man3/system.3.html while((w = wait()) && w->pid != pid) free(w); + if(w == nil) + return -1; if(w->msg[0] != 0){ s = strstr(w->msg, __POSIX_EXIT_PREFIX); if(s){