summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2019-11-01 03:54:34 +0000
committerDamien Miller <djm@cvs.openbsd.org>2019-11-01 03:54:34 +0000
commit3cb65762769628dde5dafa4ccaf771f35e244eb8 (patch)
tree336fa7e692db45e7a8a4c51d2cbc6048e360f37f
parentb1d3ea3601b2216a0cc9cc84432190c2cb324eb5 (diff)
fix a race condition in the SIGCHILD handler that could turn in
to a kill(-1); bz3084, reported by Gao Rui, ok dtucker@
-rw-r--r--usr.bin/ssh/sftp.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c
index 1a5449886b6..922382dfa24 100644
--- a/usr.bin/ssh/sftp.c
+++ b/usr.bin/ssh/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.195 2019/10/02 00:42:30 djm Exp $ */
+/* $OpenBSD: sftp.c,v 1.196 2019/11/01 03:54:33 djm Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -198,9 +198,12 @@ static const struct CMD cmds[] = {
static void
killchild(int signo)
{
- if (sshpid > 1) {
- kill(sshpid, SIGTERM);
- waitpid(sshpid, NULL, 0);
+ pid_t pid;
+
+ pid = sshpid;
+ if (pid > 1) {
+ kill(pid, SIGTERM);
+ waitpid(pid, NULL, 0);
}
_exit(1);