svn commit: r315728 - head/lib/libproc
Mark Johnston
markj at FreeBSD.org
Wed Mar 22 18:31:46 UTC 2017
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 at 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);
More information about the svn-src-all
mailing list