summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2024-06-11 00:44:53 +0000
committerDamien Miller <djm@cvs.openbsd.org>2024-06-11 00:44:53 +0000
commite81d8d84da7dc5baafc9d8b096291c26dfda516e (patch)
treec0a965ca7f48dc9af95ee6fbf47c216dea2ee9b0
parent9900371311a536a9da44c7dc00a2c6cc24fcd9ec (diff)
reap the [net] child if it hangs up while writing privsep message
payloads, not just the message header
-rw-r--r--usr.bin/ssh/monitor_wrap.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/ssh/monitor_wrap.c b/usr.bin/ssh/monitor_wrap.c
index 9581c3e3d00..9b06f152f20 100644
--- a/usr.bin/ssh/monitor_wrap.c
+++ b/usr.bin/ssh/monitor_wrap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor_wrap.c,v 1.132 2024/06/11 00:40:21 djm Exp $ */
+/* $OpenBSD: monitor_wrap.c,v 1.133 2024/06/11 00:44:52 djm Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -171,7 +171,7 @@ mm_request_receive(int sock, struct sshbuf *m)
{
u_char buf[4], *p = NULL;
u_int msg_len;
- int r;
+ int oerrno, r;
debug3_f("entering");
@@ -189,8 +189,13 @@ mm_request_receive(int sock, struct sshbuf *m)
sshbuf_reset(m);
if ((r = sshbuf_reserve(m, msg_len, &p)) != 0)
fatal_fr(r, "reserve");
- if (atomicio(read, sock, p, msg_len) != msg_len)
- fatal_f("read: %s", strerror(errno));
+ if (atomicio(read, sock, p, msg_len) != msg_len) {
+ oerrno = errno;
+ error_f("read: %s", strerror(errno));
+ if (oerrno == EPIPE)
+ mm_reap();
+ cleanup_exit(255);
+ }
}
void