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/88d5dac18595
branches: netbsd-9
changeset: 983928:88d5dac18595
user: martin <martin%NetBSD.org@localhost>
date: Mon Jun 14 11:22:16 2021 +0000
description:
Pull up following revision(s) (requested by lukem in ticket #1290):
usr.bin/ftp/version.h: revision 1.90
usr.bin/ftp/ftp.c: revision 1.170
ftp.c: improve signal handler restoration
Only invoke the old signal handler if it's a real signal handler
and not SIG_IGN, SIG_DFL, SIG_HOLD, or SIG_ERR, using new static
function issighandler().
Avoids an intermittent race condition with a null pointer
dereference via (*SIG_DFL)().
Bug class reported by Joyu Liao from Juniper Networks.
Use SIG_ERR instead of NULL as the indicator that a signal handler
hasn't been changed, so that SIG_DFL (equivalent to NULL)
will be restored.
diffstat:
usr.bin/ftp/ftp.c | 61 ++++++++++++++++++++++++++++++++------------------
usr.bin/ftp/version.h | 4 +-
2 files changed, 41 insertions(+), 24 deletions(-)
diffs (195 lines):
diff -r fcbf066a0020 -r 88d5dac18595 usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Wed Jun 09 19:47:29 2021 +0000
+++ b/usr.bin/ftp/ftp.c Mon Jun 14 11:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ftp.c,v 1.168.2.1 2021/01/29 20:58:19 martin Exp $ */
+/* $NetBSD: ftp.c,v 1.168.2.2 2021/06/14 11:22:16 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.1 2021/01/29 20:58:19 martin Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.168.2.2 2021/06/14 11:22:16 martin Exp $");
#endif
#endif /* not lint */
@@ -320,6 +320,17 @@
errno = oerrno;
}
+static int
+issighandler(sigfunc func)
+{
+ return (func != SIG_IGN &&
+ func != SIG_DFL &&
+#ifdef SIG_HOLD
+ func != SIG_HOLD &&
+#endif
+ func != SIG_ERR);
+}
+
/*VARARGS*/
int
command(const char *fmt, ...)
@@ -359,8 +370,9 @@
(void)fflush(cout);
cpend = 1;
r = getreply(!strcmp(fmt, "QUIT"));
- if (abrtflag && oldsigint != SIG_IGN)
+ if (abrtflag && issighandler(oldsigint)) {
(*oldsigint)(SIGINT);
+ }
(void)xsignal(SIGINT, oldsigint);
return (r);
}
@@ -510,11 +522,14 @@
(void)xsignal(SIGALRM, oldsigalrm);
if (code == 421 || originalcode == 421)
lostpeer(0);
- if (abrtflag && oldsigint != cmdabort && oldsigint != SIG_IGN)
+ if (abrtflag && oldsigint != cmdabort &&
+ issighandler(oldsigint)) {
(*oldsigint)(SIGINT);
+ }
if (timeoutflag && oldsigalrm != cmdtimeout &&
- oldsigalrm != SIG_IGN)
+ issighandler(oldsigalrm)) {
(*oldsigalrm)(SIGINT);
+ }
return (n - '0');
}
}
@@ -680,7 +695,7 @@
FILE *volatile dout;
int (*volatile closefunc)(FILE *);
sigfunc volatile oldintr;
- sigfunc volatile oldintp;
+ sigfunc volatile oldpipe;
off_t volatile hashbytes;
int hash_interval;
const char *lmode;
@@ -707,8 +722,8 @@
if (curtype != type)
changetype(type, 0);
closefunc = NULL;
- oldintr = NULL;
- oldintp = NULL;
+ oldintr = SIG_ERR;
+ oldpipe = SIG_ERR;
lmode = "w";
if (sigsetjmp(xferabort, 1)) {
while (cpend)
@@ -722,7 +737,7 @@
fin = stdin;
progress = 0;
} else if (*local == '|') {
- oldintp = xsignal(SIGPIPE, SIG_IGN);
+ oldpipe = xsignal(SIGPIPE, SIG_IGN);
fin = popen(local + 1, "r");
if (fin == NULL) {
warn("Can't execute `%s'", local + 1);
@@ -796,7 +811,9 @@
}
progressmeter(-1);
- oldintp = xsignal(SIGPIPE, SIG_IGN);
+ if (oldpipe == SIG_ERR) {
+ oldpipe = xsignal(SIGPIPE, SIG_IGN);
+ }
hash_interval = (hash && (!progress || filesize < 0)) ? mark : 0;
switch (curtype) {
@@ -865,7 +882,7 @@
abort:
(void)xsignal(SIGINT, oldintr);
- oldintr = NULL;
+ oldintr = SIG_ERR;
if (!cpend) {
code = -1;
goto cleanupsend;
@@ -884,10 +901,10 @@
ptransfer(0);
cleanupsend:
- if (oldintr)
+ if (oldintr != SIG_ERR)
(void)xsignal(SIGINT, oldintr);
- if (oldintp)
- (void)xsignal(SIGPIPE, oldintp);
+ if (oldpipe != SIG_ERR)
+ (void)xsignal(SIGPIPE, oldpipe);
if (data >= 0) {
(void)close(data);
data = -1;
@@ -909,7 +926,7 @@
FILE *volatile din;
int (*volatile closefunc)(FILE *);
sigfunc volatile oldintr;
- sigfunc volatile oldintp;
+ sigfunc volatile oldpipe;
int c, d;
int volatile is_retr;
int volatile tcrflag;
@@ -945,8 +962,8 @@
return;
}
closefunc = NULL;
- oldintr = NULL;
- oldintp = NULL;
+ oldintr = SIG_ERR;
+ oldpipe = SIG_ERR;
tcrflag = !crflag && is_retr;
if (sigsetjmp(xferabort, 1)) {
while (cpend)
@@ -1027,7 +1044,7 @@
progress = 0;
preserve = 0;
} else if (!ignorespecial && *local == '|') {
- oldintp = xsignal(SIGPIPE, SIG_IGN);
+ oldpipe = xsignal(SIGPIPE, SIG_IGN);
fout = popen(local + 1, "w");
if (fout == NULL) {
warn("Can't execute `%s'", local+1);
@@ -1193,10 +1210,10 @@
ptransfer(0);
cleanuprecv:
- if (oldintr)
+ if (oldintr != SIG_ERR)
(void)xsignal(SIGINT, oldintr);
- if (oldintp)
- (void)xsignal(SIGPIPE, oldintp);
+ if (oldpipe != SIG_ERR)
+ (void)xsignal(SIGPIPE, oldpipe);
if (data >= 0) {
(void)close(data);
data = -1;
@@ -1866,7 +1883,7 @@
int volatile secndflag;
const char *volatile cmd2;
- oldintr = NULL;
+ oldintr = SIG_ERR;
secndflag = 0;
if (strcmp(cmd, "RETR"))
cmd2 = "RETR";
diff -r fcbf066a0020 -r 88d5dac18595 usr.bin/ftp/version.h
--- a/usr.bin/ftp/version.h Wed Jun 09 19:47:29 2021 +0000
+++ b/usr.bin/ftp/version.h Mon Jun 14 11:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.87.18.1 2021/01/29 20:58:19 martin Exp $ */
+/* $NetBSD: version.h,v 1.87.18.2 2021/06/14 11:22:16 martin Exp $ */
/*-
* Copyright (c) 1999-2021 The NetBSD Foundation, Inc.
@@ -34,5 +34,5 @@
#endif
#ifndef FTP_VERSION
-#define FTP_VERSION "20210106"
+#define FTP_VERSION "20200711"
#endif
Home |
Main Index |
Thread Index |
Old Index