Date: Wed, 22 Mar 2017 18:31:44 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315728 - head/lib/libproc Message-ID: <201703221831.v2MIVivp048938@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Wed Mar 22 18:31:44 2017 New Revision: 315728 URL: https://svnweb.freebsd.org/changeset/base/315728 Log: Avoid accessing an uninitialized variable when vfork() fails. Reported by: Miles Ohlrich <miles.ohlrich@isilon.com> MFC after: 1 week Sponsored by: Dell EMC Isilon Modified: head/lib/libproc/proc_create.c Modified: head/lib/libproc/proc_create.c ============================================================================== --- head/lib/libproc/proc_create.c Wed Mar 22 18:14:55 2017 (r315727) +++ head/lib/libproc/proc_create.c Wed Mar 22 18:31:44 2017 (r315728) @@ -178,8 +178,7 @@ proc_create(const char *file, char * con void *child_arg, struct proc_handle **pphdl) { struct proc_handle *phdl; - int error = 0; - int status; + int error, status; pid_t pid; if (elf_version(EV_CURRENT) == EV_NONE) @@ -217,16 +216,17 @@ proc_create(const char *file, char * con /* Check for an unexpected status. */ if (!WIFSTOPPED(status)) { - error = errno; + error = EBUSY; DPRINTFX("ERROR: child process %d status 0x%x", pid, status); goto bad; - } else - phdl->status = PS_STOP; - } + } + phdl->status = PS_STOP; + bad: - if (error && phdl != NULL) { - proc_free(phdl); - phdl = NULL; + if (error != 0 && phdl != NULL) { + proc_free(phdl); + phdl = NULL; + } } *pphdl = phdl; return (error);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703221831.v2MIVivp048938>