Fri Jan 29 20:58:19 2021 UTC ()
Pull up following revision(s) (requested by lukem in ticket #1190):

	usr.bin/ftp/progressbar.c: revision 1.24
	usr.bin/ftp/ssl.c: revision 1.9
	usr.bin/ftp/progressbar.h: revision 1.9
	usr.bin/ftp/ftp.c: revision 1.171
	usr.bin/ftp/version.h: revision 1.92

ftp: don't use restartable signals

Refactor to not rely upon restartable signals (SA_RESTART),
possibly fixing intermittent failures with -q QUITTIME.
ftp transfers: handle EINTR/EAGAIN in copy_bytes(),
instead of relying upon restartable signals.

http/https transfers: Explicitly print an error similar to
progressmeter() when timing-out for -Q QUITTIME in fetch_wait(),
and set errno to ETIMEDOUT so that the warn() in fetch_url()
prints a more accurate error message.

PR/55857


(martin)
diff -r1.168 -r1.168.2.1 src/usr.bin/ftp/ftp.c
diff -r1.23 -r1.23.2.1 src/usr.bin/ftp/progressbar.c
diff -r1.8 -r1.8.48.1 src/usr.bin/ftp/progressbar.h
diff -r1.8 -r1.8.2.1 src/usr.bin/ftp/ssl.c
diff -r1.87 -r1.87.18.1 src/usr.bin/ftp/version.h

cvs diff -r1.168 -r1.168.2.1 src/usr.bin/ftp/ftp.c (expand / switch to unified diff)

--- src/usr.bin/ftp/ftp.c 2019/02/04 04:09:13 1.168
+++ src/usr.bin/ftp/ftp.c 2021/01/29 20:58:19 1.168.2.1
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1/* $NetBSD: ftp.c,v 1.168 2019/02/04 04:09:13 mrg Exp $ */ 1/* $NetBSD: ftp.c,v 1.168.2.1 2021/01/29 20:58:19 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996-2021 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Luke Mewburn. 8 * by Luke Mewburn.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
@@ -82,27 +82,27 @@ @@ -82,27 +82,27 @@
82 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 82 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
83 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 83 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
84 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 84 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
85 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 85 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
86 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 86 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
87 * SUCH DAMAGE. 87 * SUCH DAMAGE.
88 */ 88 */
89 89
90#include <sys/cdefs.h> 90#include <sys/cdefs.h>
91#ifndef lint 91#ifndef lint
92#if 0 92#if 0
93static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; 93static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
94#else 94#else
95__RCSID("$NetBSD: ftp.c,v 1.168 2019/02/04 04:09:13 mrg Exp $"); 95__RCSID("$NetBSD: ftp.c,v 1.168.2.1 2021/01/29 20:58:19 martin Exp $");
96#endif 96#endif
97#endif /* not lint */ 97#endif /* not lint */
98 98
99#include <sys/types.h> 99#include <sys/types.h>
100#include <sys/stat.h> 100#include <sys/stat.h>
101#include <sys/socket.h> 101#include <sys/socket.h>
102#include <sys/time.h> 102#include <sys/time.h>
103 103
104#include <netinet/in.h> 104#include <netinet/in.h>
105#include <netinet/in_systm.h> 105#include <netinet/in_systm.h>
106#include <netinet/ip.h> 106#include <netinet/ip.h>
107#include <arpa/inet.h> 107#include <arpa/inet.h>
108#include <arpa/ftp.h> 108#include <arpa/ftp.h>
@@ -568,27 +568,27 @@ abortxfer(int notused) @@ -568,27 +568,27 @@ abortxfer(int notused)
568 strlcpy(msgbuf, "\nsend", sizeof(msgbuf)); 568 strlcpy(msgbuf, "\nsend", sizeof(msgbuf));
569 break; 569 break;
570 default: 570 default:
571 errx(1, "abortxfer: unknown direction `%s'", direction); 571 errx(1, "abortxfer: unknown direction `%s'", direction);
572 } 572 }
573 len = strlcat(msgbuf, " aborted. Waiting for remote to finish abort.\n", 573 len = strlcat(msgbuf, " aborted. Waiting for remote to finish abort.\n",
574 sizeof(msgbuf)); 574 sizeof(msgbuf));
575 write(fileno(ttyout), msgbuf, len); 575 write(fileno(ttyout), msgbuf, len);
576 siglongjmp(xferabort, 1); 576 siglongjmp(xferabort, 1);
577} 577}
578 578
579/* 579/*
580 * Read data from infd & write to outfd, using buf/bufsize as the temporary 580 * Read data from infd & write to outfd, using buf/bufsize as the temporary
581 * buffer, dealing with short writes. 581 * buffer, dealing with short reads or writes.
582 * If rate_limit != 0, rate-limit the transfer. 582 * If rate_limit != 0, rate-limit the transfer.
583 * If hash_interval != 0, fputc('c', ttyout) every hash_interval bytes. 583 * If hash_interval != 0, fputc('c', ttyout) every hash_interval bytes.
584 * Updates global variables: bytes. 584 * Updates global variables: bytes.
585 * Returns 0 if ok, 1 if there was a read error, 2 if there was a write error. 585 * Returns 0 if ok, 1 if there was a read error, 2 if there was a write error.
586 * In the case of error, errno contains the appropriate error code. 586 * In the case of error, errno contains the appropriate error code.
587 */ 587 */
588static int 588static int
589copy_bytes(int infd, int outfd, char *buf, size_t bufsize, 589copy_bytes(int infd, int outfd, char *buf, size_t bufsize,
590 int rate_limit, int hash_interval) 590 int rate_limit, int hash_interval)
591{ 591{
592 volatile off_t hashc; 592 volatile off_t hashc;
593 ssize_t inc, outc; 593 ssize_t inc, outc;
594 char *bufp; 594 char *bufp;
@@ -602,35 +602,45 @@ copy_bytes(int infd, int outfd, char *bu @@ -602,35 +602,45 @@ copy_bytes(int infd, int outfd, char *bu
602 else 602 else
603 bufchunk = bufsize; 603 bufchunk = bufsize;
604 604
605 while (1) { 605 while (1) {
606 if (rate_limit) { 606 if (rate_limit) {
607 (void)gettimeofday(&tvthen, NULL); 607 (void)gettimeofday(&tvthen, NULL);
608 } 608 }
609 errno = 0; 609 errno = 0;
610 inc = outc = 0; 610 inc = outc = 0;
611 /* copy bufchunk at a time */ 611 /* copy bufchunk at a time */
612 bufrem = bufchunk; 612 bufrem = bufchunk;
613 while (bufrem > 0) { 613 while (bufrem > 0) {
614 inc = read(infd, buf, MIN((off_t)bufsize, bufrem)); 614 inc = read(infd, buf, MIN((off_t)bufsize, bufrem));
615 if (inc <= 0) 615 if (inc < 0) {
 616 if (errno == EINTR || errno == EAGAIN) {
 617 continue;
 618 }
 619 goto copy_done;
 620 } else if (inc == 0) {
616 goto copy_done; 621 goto copy_done;
 622 }
617 bytes += inc; 623 bytes += inc;
618 bufrem -= inc; 624 bufrem -= inc;
619 bufp = buf; 625 bufp = buf;
620 while (inc > 0) { 626 while (inc > 0) {
621 outc = write(outfd, bufp, inc); 627 outc = write(outfd, bufp, inc);
622 if (outc < 0) 628 if (outc < 0) {
 629 if (errno == EINTR || errno == EAGAIN) {
 630 continue;
 631 }
623 goto copy_done; 632 goto copy_done;
 633 }
624 inc -= outc; 634 inc -= outc;
625 bufp += outc; 635 bufp += outc;
626 } 636 }
627 if (hash_interval) { 637 if (hash_interval) {
628 while (bytes >= hashc) { 638 while (bytes >= hashc) {
629 (void)putc('#', ttyout); 639 (void)putc('#', ttyout);
630 hashc += hash_interval; 640 hashc += hash_interval;
631 } 641 }
632 (void)fflush(ttyout); 642 (void)fflush(ttyout);
633 } 643 }
634 } 644 }
635 if (rate_limit) { /* rate limited; wait if necessary */ 645 if (rate_limit) { /* rate limited; wait if necessary */
636 while (1) { 646 while (1) {

cvs diff -r1.23 -r1.23.2.1 src/usr.bin/ftp/progressbar.c (expand / switch to unified diff)

--- src/usr.bin/ftp/progressbar.c 2019/06/22 23:40:33 1.23
+++ src/usr.bin/ftp/progressbar.c 2021/01/29 20:58:19 1.23.2.1
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1/* $NetBSD: progressbar.c,v 1.23 2019/06/22 23:40:33 christos Exp $ */ 1/* $NetBSD: progressbar.c,v 1.23.2.1 2021/01/29 20:58:19 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997-2021 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Luke Mewburn. 8 * by Luke Mewburn.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__RCSID("$NetBSD: progressbar.c,v 1.23 2019/06/22 23:40:33 christos Exp $"); 34__RCSID("$NetBSD: progressbar.c,v 1.23.2.1 2021/01/29 20:58:19 martin Exp $");
35#endif /* not lint */ 35#endif /* not lint */
36 36
37/* 37/*
38 * FTP User Program -- Misc support routines 38 * FTP User Program -- Misc support routines
39 */ 39 */
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/types.h> 41#include <sys/types.h>
42#include <sys/time.h> 42#include <sys/time.h>
43 43
44#include <err.h> 44#include <err.h>
45#include <errno.h> 45#include <errno.h>
46#include <signal.h> 46#include <signal.h>
47#include <stdio.h> 47#include <stdio.h>
@@ -183,27 +183,27 @@ progressmeter(int flag) @@ -183,27 +183,27 @@ progressmeter(int flag)
183 siglongjmp(toplevel, 1); 183 siglongjmp(toplevel, 1);
184 } 184 }
185#endif /* !STANDALONE_PROGRESS */ 185#endif /* !STANDALONE_PROGRESS */
186 } 186 }
187 /* 187 /*
188 * Always set the handler even if we are not the foreground process. 188 * Always set the handler even if we are not the foreground process.
189 */ 189 */
190#ifdef STANDALONE_PROGRESS 190#ifdef STANDALONE_PROGRESS
191 if (progress) { 191 if (progress) {
192#else 192#else
193 if (quit_time > 0 || progress) { 193 if (quit_time > 0 || progress) {
194#endif /* !STANDALONE_PROGRESS */ 194#endif /* !STANDALONE_PROGRESS */
195 if (flag == -1) { 195 if (flag == -1) {
196 (void)xsignal_restart(SIGALRM, updateprogressmeter, 1); 196 (void)xsignal(SIGALRM, updateprogressmeter);
197 alarmtimer(1); /* set alarm timer for 1 Hz */ 197 alarmtimer(1); /* set alarm timer for 1 Hz */
198 } else if (flag == 1) { 198 } else if (flag == 1) {
199 alarmtimer(0); 199 alarmtimer(0);
200 (void)xsignal(SIGALRM, SIG_DFL); 200 (void)xsignal(SIGALRM, SIG_DFL);
201 } 201 }
202 } 202 }
203#ifndef NO_PROGRESS 203#ifndef NO_PROGRESS
204 if (!progress) 204 if (!progress)
205 return; 205 return;
206 len = 0; 206 len = 0;
207 207
208 /* 208 /*
209 * print progress bar only if we are foreground process. 209 * print progress bar only if we are foreground process.
@@ -394,83 +394,31 @@ psummary(int notused) @@ -394,83 +394,31 @@ psummary(int notused)
394 * Set the SIGALRM interval timer for wait seconds, 0 to disable. 394 * Set the SIGALRM interval timer for wait seconds, 0 to disable.
395 */ 395 */
396void 396void
397alarmtimer(int wait) 397alarmtimer(int wait)
398{ 398{
399 struct itimerval itv; 399 struct itimerval itv;
400 400
401 itv.it_value.tv_sec = wait; 401 itv.it_value.tv_sec = wait;
402 itv.it_value.tv_usec = 0; 402 itv.it_value.tv_usec = 0;
403 itv.it_interval = itv.it_value; 403 itv.it_interval = itv.it_value;
404 setitimer(ITIMER_REAL, &itv, NULL); 404 setitimer(ITIMER_REAL, &itv, NULL);
405} 405}
406 406
407 
408/* 407/*
409 * Install a POSIX signal handler, allowing the invoker to set whether 408 * Install a non-restartable POSIX signal handler.
410 * the signal should be restartable or not 
411 */ 409 */
412sigfunc 410sigfunc
413xsignal_restart(int sig, sigfunc func, int restartable) 411xsignal(int sig, sigfunc func)
414{ 412{
415 struct sigaction act, oact; 413 struct sigaction act, oact;
416 act.sa_handler = func; 414 act.sa_handler = func;
417 415
418 sigemptyset(&act.sa_mask); 416 sigemptyset(&act.sa_mask);
419#if defined(SA_RESTART) /* 4.4BSD, Posix(?), SVR4 */ 417 act.sa_flags = 0;
420 act.sa_flags = restartable ? SA_RESTART : 0; 418#if defined(SA_INTERRUPT) /* SunOS 4.x */
421#elif defined(SA_INTERRUPT) /* SunOS 4.x */ 419 act.sa_flags = SA_INTERRUPT;
422 act.sa_flags = restartable ? 0 : SA_INTERRUPT; 
423#else 
424#error "system must have SA_RESTART or SA_INTERRUPT" 
425#endif 420#endif
426 if (sigaction(sig, &act, &oact) < 0) 421 if (sigaction(sig, &act, &oact) < 0)
427 return (SIG_ERR); 422 return (SIG_ERR);
428 return (oact.sa_handler); 423 return (oact.sa_handler);
429} 424}
430 
431/* 
432 * Install a signal handler with the `restartable' flag set dependent upon 
433 * which signal is being set. (This is a wrapper to xsignal_restart()) 
434 */ 
435sigfunc 
436xsignal(int sig, sigfunc func) 
437{ 
438 int restartable; 
439 
440 /* 
441 * Some signals print output or change the state of the process. 
442 * There should be restartable, so that reads and writes are 
443 * not affected. Some signals should cause program flow to change; 
444 * these signals should not be restartable, so that the system call 
445 * will return with EINTR, and the program will go do something 
446 * different. If the signal handler calls longjmp() or siglongjmp(), 
447 * it doesn't matter if it's restartable. 
448 */ 
449 
450 switch(sig) { 
451#ifdef SIGINFO 
452 case SIGINFO: 
453#endif 
454 case SIGQUIT: 
455 case SIGUSR1: 
456 case SIGUSR2: 
457 case SIGWINCH: 
458 restartable = 1; 
459 break; 
460 
461 case SIGALRM: 
462 case SIGINT: 
463 case SIGPIPE: 
464 restartable = 0; 
465 break; 
466 
467 default: 
468 /* 
469 * This is unpleasant, but I don't know what would be better. 
470 * Right now, this "can't happen" 
471 */ 
472 errx(1, "xsignal_restart: called with signal %d", sig); 
473 } 
474 
475 return(xsignal_restart(sig, func, restartable)); 
476} 

cvs diff -r1.8 -r1.8.48.1 src/usr.bin/ftp/progressbar.h (expand / switch to unified diff)

--- src/usr.bin/ftp/progressbar.h 2009/04/12 10:18:52 1.8
+++ src/usr.bin/ftp/progressbar.h 2021/01/29 20:58:19 1.8.48.1
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1/* $NetBSD: progressbar.h,v 1.8 2009/04/12 10:18:52 lukem Exp $ */ 1/* $NetBSD: progressbar.h,v 1.8.48.1 2021/01/29 20:58:19 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996-2021 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Luke Mewburn. 8 * by Luke Mewburn.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
@@ -58,27 +58,26 @@ GLOBAL char *prefix; /* Text written  @@ -58,27 +58,26 @@ GLOBAL char *prefix; /* Text written
58GLOBAL int fromatty; /* input is from a terminal */ 58GLOBAL int fromatty; /* input is from a terminal */
59GLOBAL int verbose; /* print messages coming back from server */ 59GLOBAL int verbose; /* print messages coming back from server */
60GLOBAL int quit_time; /* maximum time to wait if stalled */ 60GLOBAL int quit_time; /* maximum time to wait if stalled */
61 61
62GLOBAL const char *direction; /* direction transfer is occurring */ 62GLOBAL const char *direction; /* direction transfer is occurring */
63 63
64GLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */ 64GLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */
65#endif /* !STANDALONE_PROGRESS */ 65#endif /* !STANDALONE_PROGRESS */
66 66
67int foregroundproc(void); 67int foregroundproc(void);
68void alarmtimer(int); 68void alarmtimer(int);
69void progressmeter(int); 69void progressmeter(int);
70sigfunc xsignal(int, sigfunc); 70sigfunc xsignal(int, sigfunc);
71sigfunc xsignal_restart(int, sigfunc, int); 
72 71
73#ifndef STANDALONE_PROGRESS 72#ifndef STANDALONE_PROGRESS
74void psummary(int); 73void psummary(int);
75void ptransfer(int); 74void ptransfer(int);
76#endif /* !STANDALONE_PROGRESS */ 75#endif /* !STANDALONE_PROGRESS */
77 76
78#ifdef NO_LONG_LONG 77#ifdef NO_LONG_LONG
79# define LLF "%ld" 78# define LLF "%ld"
80# define LLFP(x) "%" x "ld" 79# define LLFP(x) "%" x "ld"
81# define LLT long 80# define LLT long
82# define ULLF "%lu" 81# define ULLF "%lu"
83# define ULLFP(x) "%" x "lu" 82# define ULLFP(x) "%" x "lu"
84# define ULLT unsigned long 83# define ULLT unsigned long

cvs diff -r1.8 -r1.8.2.1 src/usr.bin/ftp/ssl.c (expand / switch to unified diff)

--- src/usr.bin/ftp/ssl.c 2019/04/07 00:44:54 1.8
+++ src/usr.bin/ftp/ssl.c 2021/01/29 20:58:19 1.8.2.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ssl.c,v 1.8 2019/04/07 00:44:54 christos Exp $ */ 1/* $NetBSD: ssl.c,v 1.8.2.1 2021/01/29 20:58:19 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav 4 * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
5 * Copyright (c) 2008, 2010 Joerg Sonnenberger <joerg@NetBSD.org> 5 * Copyright (c) 2008, 2010 Joerg Sonnenberger <joerg@NetBSD.org>
6 * Copyright (c) 2015 Thomas Klausner <wiz@NetBSD.org> 6 * Copyright (c) 2015 Thomas Klausner <wiz@NetBSD.org>
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer 13 * notice, this list of conditions and the following disclaimer
14 * in this position and unchanged. 14 * in this position and unchanged.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * 31 *
32 * $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $ 32 * $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36#ifndef lint 36#ifndef lint
37__RCSID("$NetBSD: ssl.c,v 1.8 2019/04/07 00:44:54 christos Exp $"); 37__RCSID("$NetBSD: ssl.c,v 1.8.2.1 2021/01/29 20:58:19 martin Exp $");
38#endif 38#endif
39 39
40#include <time.h> 40#include <time.h>
41#include <unistd.h> 41#include <unistd.h>
42#include <string.h> 42#include <string.h>
43#include <fcntl.h> 43#include <fcntl.h>
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#include <sys/select.h> 46#include <sys/select.h>
47#include <sys/uio.h> 47#include <sys/uio.h>
48 48
49#include <netinet/tcp.h> 49#include <netinet/tcp.h>
50#include <netinet/in.h> 50#include <netinet/in.h>
@@ -346,26 +346,30 @@ fetch_cache_data(struct fetch_connect *c @@ -346,26 +346,30 @@ fetch_cache_data(struct fetch_connect *c
346static int 346static int
347fetch_wait(struct fetch_connect *conn, ssize_t rlen, struct timeval *timeout) 347fetch_wait(struct fetch_connect *conn, ssize_t rlen, struct timeval *timeout)
348{ 348{
349 struct timeval now, delta; 349 struct timeval now, delta;
350 int fd = conn->sd; 350 int fd = conn->sd;
351 fd_set fds; 351 fd_set fds;
352 352
353 FD_ZERO(&fds); 353 FD_ZERO(&fds);
354 while (!FD_ISSET(fd, &fds)) { 354 while (!FD_ISSET(fd, &fds)) {
355 FD_SET(fd, &fds); 355 FD_SET(fd, &fds);
356 if (quit_time > 0) { 356 if (quit_time > 0) {
357 gettimeofday(&now, NULL); 357 gettimeofday(&now, NULL);
358 if (!timercmp(timeout, &now, >)) { 358 if (!timercmp(timeout, &now, >)) {
 359 fprintf(ttyout, "\r\n%s: transfer aborted"
 360 " because stalled for %lu sec.\r\n",
 361 getprogname(), (unsigned long)quit_time);
 362 errno = ETIMEDOUT;
359 conn->iserr = ETIMEDOUT; 363 conn->iserr = ETIMEDOUT;
360 return -1; 364 return -1;
361 } 365 }
362 timersub(timeout, &now, &delta); 366 timersub(timeout, &now, &delta);
363 } 367 }
364 errno = 0; 368 errno = 0;
365 if (select(fd + 1, 369 if (select(fd + 1,
366 rlen == FETCH_READ_WAIT ? &fds : NULL, 370 rlen == FETCH_READ_WAIT ? &fds : NULL,
367 rlen == FETCH_WRITE_WAIT ? &fds : NULL, 371 rlen == FETCH_WRITE_WAIT ? &fds : NULL,
368 NULL, quit_time > 0 ? &delta : NULL) < 0) { 372 NULL, quit_time > 0 ? &delta : NULL) < 0) {
369 if (errno == EINTR) 373 if (errno == EINTR)
370 continue; 374 continue;
371 conn->iserr = errno; 375 conn->iserr = errno;

cvs diff -r1.87 -r1.87.18.1 src/usr.bin/ftp/version.h (expand / switch to unified diff)

--- src/usr.bin/ftp/version.h 2015/09/12 20:18:52 1.87
+++ src/usr.bin/ftp/version.h 2021/01/29 20:58:19 1.87.18.1
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1/* $NetBSD: version.h,v 1.87 2015/09/12 20:18:52 wiz Exp $ */ 1/* $NetBSD: version.h,v 1.87.18.1 2021/01/29 20:58:19 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999-2015 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999-2021 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Luke Mewburn. 8 * by Luke Mewburn.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
@@ -24,15 +24,15 @@ @@ -24,15 +24,15 @@
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef FTP_PRODUCT 32#ifndef FTP_PRODUCT
33#define FTP_PRODUCT "NetBSD-ftp" 33#define FTP_PRODUCT "NetBSD-ftp"
34#endif 34#endif
35 35
36#ifndef FTP_VERSION 36#ifndef FTP_VERSION
37#define FTP_VERSION "20150912" 37#define FTP_VERSION "20210106"
38#endif 38#endif