Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/usr.bin/ftp Pull up following revision(s) (requested by l...



details:   https://anonhg.NetBSD.org/src/rev/22c20ba1d442
branches:  netbsd-9
changeset: 983929:22c20ba1d442
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Jun 14 11:28:28 2021 +0000

description:
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:

 usr.bin/ftp/ftp.c  |   8 ++++----
 usr.bin/ftp/util.c |  12 ++++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diffs (80 lines):

diff -r 88d5dac18595 -r 22c20ba1d442 usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Mon Jun 14 11:22:16 2021 +0000
+++ b/usr.bin/ftp/ftp.c Mon Jun 14 11:28:28 2021 +0000
@@ -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 @@
  *     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 @@
        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 88d5dac18595 -r 22c20ba1d442 usr.bin/ftp/util.c
--- a/usr.bin/ftp/util.c        Mon Jun 14 11:22:16 2021 +0000
+++ b/usr.bin/ftp/util.c        Mon Jun 14 11:28:28 2021 +0000
@@ -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 @@
 /*
  * 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;
 }
 



Home | Main Index | Thread Index | Old Index