summaryrefslogtreecommitdiff
path: root/lib/libproc
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2017-03-22 18:31:44 +0000
committerMark Johnston <markj@FreeBSD.org>2017-03-22 18:31:44 +0000
commit8440c5e621668d15ab3157f0d6f4a8d1d8507ed1 (patch)
tree582b35c3d5abb0d21e197f540a9e1136e11cf8a3 /lib/libproc
parent48da4e2024b69efe59b0d69687ea028b83005fbd (diff)
downloadsrc-test-8440c5e621668d15ab3157f0d6f4a8d1d8507ed1.tar.gz
src-test-8440c5e621668d15ab3157f0d6f4a8d1d8507ed1.zip
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
Notes
Notes: svn path=/head/; revision=315728
Diffstat (limited to 'lib/libproc')
-rw-r--r--lib/libproc/proc_create.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/libproc/proc_create.c b/lib/libproc/proc_create.c
index 69de8cb119bd3..10a53cd90eb51 100644
--- a/lib/libproc/proc_create.c
+++ b/lib/libproc/proc_create.c
@@ -178,8 +178,7 @@ proc_create(const char *file, char * const *argv, proc_child_func *pcf,
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 * const *argv, proc_child_func *pcf,
/* 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);