summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-11-01 03:54:33 +0000
committerDamien Miller <djm@mindrot.org>2019-11-01 14:56:38 +1100
commit4332b4fe49360679647a8705bc08f4e81323f6b4 (patch)
treef799d147e78be644cab1a9596cb4fedcd8d9dc37 /sftp.c
parent03f9205f0fb49ea2507eacc143737a8511ae5a4e (diff)
upstream: fix a race condition in the SIGCHILD handler that could turn
in to a kill(-1); bz3084, reported by Gao Rui, ok dtucker@ OpenBSD-Commit-ID: ac2742e04a69d4c34223505b6a32f6d686e18896
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sftp.c b/sftp.c
index b66037f16..54538ff96 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.195 2019/10/02 00:42:30 djm Exp $ */ 1/* $OpenBSD: sftp.c,v 1.196 2019/11/01 03:54:33 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -220,9 +220,12 @@ static const struct CMD cmds[] = {
220static void 220static void
221killchild(int signo) 221killchild(int signo)
222{ 222{
223 if (sshpid > 1) { 223 pid_t pid;
224 kill(sshpid, SIGTERM); 224
225 waitpid(sshpid, NULL, 0); 225 pid = sshpid;
226 if (pid > 1) {
227 kill(pid, SIGTERM);
228 waitpid(pid, NULL, 0);
226 } 229 }
227 230
228 _exit(1); 231 _exit(1);