Module Name: src
Committed By: lukem
Date: Mon Jun 8 01:33:27 UTC 2020
Modified Files:
src/usr.bin/ftp: ftp.c util.c version.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/usr.bin/ftp/ftp.c
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/ftp/util.c
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/ftp/version.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/ftp/ftp.c
diff -u src/usr.bin/ftp/ftp.c:1.168 src/usr.bin/ftp/ftp.c:1.169
--- src/usr.bin/ftp/ftp.c:1.168 Mon Feb 4 04:09:13 2019
+++ src/usr.bin/ftp/ftp.c Mon Jun 8 01:33:27 2020
@@ -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 @@ 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;
@@ -2057,7 +2057,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);
}
Index: src/usr.bin/ftp/util.c
diff -u src/usr.bin/ftp/util.c:1.160 src/usr.bin/ftp/util.c:1.161
--- src/usr.bin/ftp/util.c:1.160 Sat Jun 22 23:40:53 2019
+++ src/usr.bin/ftp/util.c Mon Jun 8 01:33:27 2020
@@ -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 @@ 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;
}
Index: src/usr.bin/ftp/version.h
diff -u src/usr.bin/ftp/version.h:1.88 src/usr.bin/ftp/version.h:1.89
--- src/usr.bin/ftp/version.h:1.88 Wed Feb 26 05:55:27 2020
+++ src/usr.bin/ftp/version.h Mon Jun 8 01:33:27 2020
@@ -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