Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ftp ftp: exit if lostpeer invoked by a signal
details: https://anonhg.NetBSD.org/src/rev/fd26c32c504a
branches: trunk
changeset: 934242:fd26c32c504a
user: lukem <lukem%NetBSD.org@localhost>
date: Mon Jun 08 01:33:27 2020 +0000
description:
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:
usr.bin/ftp/ftp.c | 10 +++++-----
usr.bin/ftp/util.c | 12 ++++++++----
usr.bin/ftp/version.h | 4 ++--
3 files changed, 15 insertions(+), 11 deletions(-)
diffs (100 lines):
diff -r 23b731cb4b40 -r fd26c32c504a usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Mon Jun 08 01:17:05 2020 +0000
+++ b/usr.bin/ftp/ftp.c Mon Jun 08 01:33:27 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: ftp.c,v 1.168 2019/02/04 04:09:13 mrg Exp $ */
+/* $NetBSD: ftp.c,v 1.169 2020/06/08 01:33:27 lukem Exp $ */
/*-
- * Copyright (c) 1996-2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996-2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -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 2019/02/04 04:09:13 mrg Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.169 2020/06/08 01:33:27 lukem Exp $");
#endif
#endif /* not lint */
@@ -2047,7 +2047,7 @@
* needs to get back to a known state.
*/
static void
-abort_squared(int dummy)
+abort_squared(int signo)
{
char msgbuf[100];
size_t len;
@@ -2057,7 +2057,7 @@
len = strlcpy(msgbuf, "\nremote abort aborted; closing connection.\n",
sizeof(msgbuf));
write(fileno(ttyout), msgbuf, len);
- lostpeer(0);
+ lostpeer(signo);
siglongjmp(xferabort, 1);
}
diff -r 23b731cb4b40 -r fd26c32c504a usr.bin/ftp/util.c
--- a/usr.bin/ftp/util.c Mon Jun 08 01:17:05 2020 +0000
+++ b/usr.bin/ftp/util.c Mon Jun 08 01:33:27 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: util.c,v 1.160 2019/06/22 23:40:53 christos Exp $ */
+/* $NetBSD: util.c,v 1.161 2020/06/08 01:33:27 lukem 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.161 2020/06/08 01:33:27 lukem Exp $");
#endif /* not lint */
/*
@@ -324,9 +324,10 @@
/*
* 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 @@
proxflag = 0;
pswitch(0);
cleanuppeer();
+ if (signo) {
+ errx(1, "lostpeer due to signal %d", signo);
+ }
errno = oerrno;
}
diff -r 23b731cb4b40 -r fd26c32c504a usr.bin/ftp/version.h
--- a/usr.bin/ftp/version.h Mon Jun 08 01:17:05 2020 +0000
+++ b/usr.bin/ftp/version.h Mon Jun 08 01:33:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.88 2020/02/26 05:55:27 lukem Exp $ */
+/* $NetBSD: version.h,v 1.89 2020/06/08 01:33:27 lukem Exp $ */
/*-
* Copyright (c) 1999-2020 The NetBSD Foundation, Inc.
@@ -34,5 +34,5 @@
#endif
#ifndef FTP_VERSION
-#define FTP_VERSION "20190622"
+#define FTP_VERSION "20200608"
#endif
Home |
Main Index |
Thread Index |
Old Index