summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2017-09-25 19:13:56 +0000
committerkrw <krw@openbsd.org>2017-09-25 19:13:56 +0000
commit2ee209bb06783d63f2142c242c03ccea15ab9795 (patch)
treedf8c09626d4083c43f30991487691477e67ecd9f
parentthe Alea I works fine with urng(4) so update the manpage accordingly (diff)
downloadwireguard-openbsd-2ee209bb06783d63f2142c242c03ccea15ab9795.tar.xz
wireguard-openbsd-2ee209bb06783d63f2142c242c03ccea15ab9795.zip
Calling waitpid(pid,...) where pid is either uninitialized or
-1 because vflork() failed is bad. Initialize pid to -1 and call waitpid() only when pid != -1. Uninitialized use of pid found by clang. Suggestion of -1 from millert@. ok millert@
-rw-r--r--usr.bin/calendar/io.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 8abe7996917..7d4353e87f5 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.46 2017/08/21 21:41:13 deraadt Exp $ */
+/* $OpenBSD: io.c,v 1.47 2017/09/25 19:13:56 krw Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -385,7 +385,7 @@ closecal(FILE *fp)
struct stat sbuf;
int nread, pdes[2], status;
char buf[1024];
- pid_t pid;
+ pid_t pid = -1;
if (!doall)
return;
@@ -422,9 +422,11 @@ closecal(FILE *fp)
(void)write(pdes[1], buf, nread);
(void)close(pdes[1]);
done: (void)fclose(fp);
- while (waitpid(pid, &status, 0) == -1) {
- if (errno != EINTR)
- break;
+ if (pid != -1) {
+ while (waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR)
+ break;
+ }
}
}