diff options
| author | martin <martin@NetBSD.org> | 2021-06-14 11:28:28 +0000 |
|---|---|---|
| committer | martin <martin@NetBSD.org> | 2021-06-14 11:28:28 +0000 |
| commit | ff5701a1963ba9e0e88e06b123725e3f13dd3e6c (patch) | |
| tree | ece3a19d70768b948641b6e6a892e3b3a6e96a05 /usr.bin | |
| parent | fd0c946904adec00e45a864768159763408845f6 (diff) | |
Pull up following revision(s) (requested by lukem in ticket #1291):
usr.bin/ftp/ftp.c: revision 1.169
usr.bin/ftp/util.c: revision 1.161
ftp: exit if lostpeer invoked by a signal
lostpeer() calls too many async-unsafe functions (both directly
and indirectly) to close and cleanup the remote connections,
so just exit after the cleanup if invoked by a signal.
Reported in private mail by Qi Hou.
May also resolve a crash reported by Thomas Klausner.
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/ftp/ftp.c | 8 | ||||
| -rw-r--r-- | usr.bin/ftp/util.c | 12 |
2 files changed, 12 insertions, 8 deletions
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index 19e553539cc..62b721cd678 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.168.2.2 2021/06/14 11:22:16 martin Exp $ */ +/* $NetBSD: ftp.c,v 1.168.2.3 2021/06/14 11:28:28 martin Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -92,7 +92,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.168.2.2 2021/06/14 11:22:16 martin Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.168.2.3 2021/06/14 11:28:28 martin Exp $"); #endif #endif /* not lint */ @@ -2074,7 +2074,7 @@ gunique(const char *local) * needs to get back to a known state. */ static void -abort_squared(int dummy) +abort_squared(int signo) { char msgbuf[100]; size_t len; @@ -2084,7 +2084,7 @@ abort_squared(int dummy) len = strlcpy(msgbuf, "\nremote abort aborted; closing connection.\n", sizeof(msgbuf)); write(fileno(ttyout), msgbuf, len); - lostpeer(0); + lostpeer(signo); siglongjmp(xferabort, 1); } diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index 621f2b0f5c8..ad5ff6e659a 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,7 +1,7 @@ -/* $NetBSD: util.c,v 1.160 2019/06/22 23:40:53 christos Exp $ */ +/* $NetBSD: util.c,v 1.160.2.1 2021/06/14 11:28:28 martin Exp $ */ /*- - * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -64,7 +64,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: util.c,v 1.160 2019/06/22 23:40:53 christos Exp $"); +__RCSID("$NetBSD: util.c,v 1.160.2.1 2021/06/14 11:28:28 martin Exp $"); #endif /* not lint */ /* @@ -324,9 +324,10 @@ intr(int signo) /* * Signal handler for lost connections; cleanup various elements of * the connection state, and call cleanuppeer() to finish it off. + * This function is not signal safe, so exit if called by a signal. */ void -lostpeer(int dummy) +lostpeer(int signo) { int oerrno = errno; @@ -356,6 +357,9 @@ lostpeer(int dummy) proxflag = 0; pswitch(0); cleanuppeer(); + if (signo) { + errx(1, "lostpeer due to signal %d", signo); + } errno = oerrno; } |
