From dca1b0d0e7409f6a473a92cd039ccc31b15056ce Mon Sep 17 00:00:00 2001 From: dtucker Date: Fri, 27 May 2022 04:27:49 +0000 Subject: [PATCH] Avoid kill with -1 argument. The out_ctx label can be reached before fork has been called. If this happens, then kill -1 would be called, sending SIGTERM to all processes reachable by the current process. From tobias@ and c3h2_ctf via github PR#286, ok djm@ --- usr.bin/ssh/readpass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.bin/ssh/readpass.c b/usr.bin/ssh/readpass.c index 4a55e98c62e..d94a21b823b 100644 --- a/usr.bin/ssh/readpass.c +++ b/usr.bin/ssh/readpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readpass.c,v 1.69 2021/07/23 05:56:47 djm Exp $ */ +/* $OpenBSD: readpass.c,v 1.70 2022/05/27 04:27:49 dtucker Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -283,7 +283,8 @@ notify_start(int force_askpass, const char *fmt, ...) } out_ctx: if ((ret = calloc(1, sizeof(*ret))) == NULL) { - kill(pid, SIGTERM); + if (pid != -1) + kill(pid, SIGTERM); fatal_f("calloc failed"); } ret->pid = pid; -- 2.20.1