summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2015-10-23 04:52:21 +0000
committerguenther <guenther@openbsd.org>2015-10-23 04:52:21 +0000
commitb2251c561ddd2e76d7c69c6dc0b22299923fe7c4 (patch)
tree750eefacf52a4b0009bd482066a2bf397eee3fbf /lib/libc
parentUse waitpid() instead of wait() to avoid returning early from another child (diff)
downloadwireguard-openbsd-b2251c561ddd2e76d7c69c6dc0b22299923fe7c4.tar.xz
wireguard-openbsd-b2251c561ddd2e76d7c69c6dc0b22299923fe7c4.zip
Fix waitpid() loop again: do the errno check only if waitpid() returns -1
and check WIFEXITED() only if it returns != -1. Delete the logging of errors other than ECHILD: EFAULT and EINVAL are impossible here. ok deraadt@ millert@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/auth_subr.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/libc/gen/auth_subr.c b/lib/libc/gen/auth_subr.c
index 0df70c4bf2c..70c9160986e 100644
--- a/lib/libc/gen/auth_subr.c
+++ b/lib/libc/gen/auth_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth_subr.c,v 1.46 2015/10/22 23:55:51 mmcc Exp $ */
+/* $OpenBSD: auth_subr.c,v 1.47 2015/10/23 04:52:21 guenther Exp $ */
/*
* Copyright (c) 2000-2002,2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -896,17 +896,17 @@ auth_call(auth_session_t *as, char *path, ...)
as->index = 0;
_auth_spool(as, pfd[0]);
close(pfd[0]);
- status = 0;
- while (waitpid(pid, &status, 0) == -1 && errno == EINTR)
- ;
- if (pid < 0) {
- if (errno != ECHILD) {
- syslog(LOG_ERR, "%s: waitpid: %m", path);
- warnx("internal failure");
- goto fail;
+ do {
+ if (waitpid(pid, &status, 0) != -1) {
+ if (!WIFEXITED(status))
+ goto fail;
+ break;
}
- } else if (!WIFEXITED(status))
- goto fail;
+ /*
+ * could get ECHILD if it was waited for by
+ * another thread or from a signal handler
+ */
+ } while (errno == EINTR);
}
/*