Module Name: src Committed By: martin Date: Mon Dec 2 10:19:39 UTC 2024
Modified Files: src/usr.bin/ftp [netbsd-10]: cmds.c extern.h fetch.c ftp.1 ftp.c main.c progressbar.c ruserpass.c util.c version.h Log Message: Pull up following revision(s) (requested by lukem in ticket #1021): usr.bin/ftp/ftp.c: revision 1.178 usr.bin/ftp/version.h: revision 1.99 usr.bin/ftp/ruserpass.c: revision 1.35 usr.bin/ftp/main.c: revision 1.134 usr.bin/ftp/main.c: revision 1.135 usr.bin/ftp/progressbar.c: revision 1.27 usr.bin/ftp/util.c: revision 1.165 usr.bin/ftp/cmds.c: revision 1.144 usr.bin/ftp/extern.h: revision 1.84 usr.bin/ftp/fetch.c: revision 1.242 usr.bin/ftp/ftp.1: revision 1.160 s/bninary/binary/ in comment. extract duplicate code into a function. Check bounds when copying to destination. Remove const where the const string ended up being overwritten. use unsigned when doing shifts. remove const when string gets overwritten. ftp: exit non-zero if short http transfer when filesize is known If a http file size is known and the fetch finishes with less bytes transferred, exit non-zero. Bump version to 20241129. PR bin/54713 PR bin/58281 ftp: help improvements Document -? as a separate mode. Document -H HEADER in the usage. Clarify units for -b and -x. Consistent argument names between ftp -? and ftp(1). ftp: order getopt Upper before lower Consistently order options in getopt and the switch with the upper case option before the lower case option. This makes it easier to cross-reference with -? and ftp(1). No functional change. To generate a diff of this commit: cvs rdiff -u -r1.141.6.1 -r1.141.6.2 src/usr.bin/ftp/cmds.c cvs rdiff -u -r1.82.10.1 -r1.82.10.2 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.235.2.3 -r1.235.2.4 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.147.2.6 -r1.147.2.7 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.174.2.2 -r1.174.2.3 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.128.2.2 -r1.128.2.3 src/usr.bin/ftp/main.c cvs rdiff -u -r1.24.6.1 -r1.24.6.2 src/usr.bin/ftp/progressbar.c cvs rdiff -u -r1.33.86.1 -r1.33.86.2 src/usr.bin/ftp/ruserpass.c cvs rdiff -u -r1.164.2.3 -r1.164.2.4 src/usr.bin/ftp/util.c cvs rdiff -u -r1.95.2.2 -r1.95.2.3 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/cmds.c diff -u src/usr.bin/ftp/cmds.c:1.141.6.1 src/usr.bin/ftp/cmds.c:1.141.6.2 --- src/usr.bin/ftp/cmds.c:1.141.6.1 Sun Oct 13 16:06:36 2024 +++ src/usr.bin/ftp/cmds.c Mon Dec 2 10:19:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cmds.c,v 1.141.6.1 2024/10/13 16:06:36 martin Exp $ */ +/* $NetBSD: cmds.c,v 1.141.6.2 2024/12/02 10:19:39 martin Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: cmds.c,v 1.141.6.1 2024/10/13 16:06:36 martin Exp $"); +__RCSID("$NetBSD: cmds.c,v 1.141.6.2 2024/12/02 10:19:39 martin Exp $"); #endif #endif /* not lint */ @@ -147,10 +147,10 @@ __dead static void mintr(int); static void mabort(const char *); static void set_type(const char *); -static const char *doprocess(char *, size_t, const char *, int, int, int); -static const char *domap(char *, size_t, const char *); -static const char *docase(char *, size_t, const char *); -static const char *dotrans(char *, size_t, const char *); +static char *doprocess(char *, size_t, char *, int, int, int); +static char *domap(char *, size_t, const char *); +static char *docase(char *, size_t, const char *); +static char *dotrans(char *, size_t, const char *); /* * Confirm if "cmd" is to be performed upon "file". @@ -407,7 +407,7 @@ put(int argc, char *argv[]) const char *cmd; int loc = 0; char *locfile; - const char *remfile; + char *remfile; if (argc == 2) { argc++; @@ -437,8 +437,8 @@ put(int argc, char *argv[]) free(locfile); } -static const char * -doprocess(char *dst, size_t dlen, const char *src, +static char * +doprocess(char *dst, size_t dlen, char *src, int casef, int transf, int mapf) { if (casef) @@ -576,8 +576,7 @@ int getit(int argc, char *argv[], int restartit, const char *gmode) { int loc, rval; - char *remfile, *olocfile; - const char *locfile; + char *remfile, *olocfile, *locfile; char buf[MAXPATHLEN]; loc = rval = 0; @@ -684,8 +683,7 @@ mget(int argc, char *argv[]) { sigfunc oldintr; int ointer; - char *cp; - const char *tp; + char *cp, *tp; int volatile restartit; if (argc == 0 || @@ -1290,13 +1288,11 @@ void ls(int argc, char *argv[]) { const char *cmd; - char *remdir, *locbuf; - const char *locfile; + char *remdir, *locbuf, *locfile; int pagecmd, mlsdcmd; remdir = NULL; locbuf = NULL; - locfile = "-"; pagecmd = mlsdcmd = 0; /* * the only commands that start with `p' are @@ -1326,6 +1322,8 @@ ls(int argc, char *argv[]) remdir = argv[1]; if (argc > 2) locfile = argv[2]; + else + locfile = locbuf = ftp_strdup("-"); if (argc > 3 || ((pagecmd | mlsdcmd) && argc > 2)) { usage: if (pagecmd || mlsdcmd) @@ -1345,11 +1343,12 @@ ls(int argc, char *argv[]) if (EMPTYSTRING(p)) p = DEFAULTPAGER; len = strlen(p) + 2; + free(locbuf); locbuf = ftp_malloc(len); locbuf[0] = '|'; (void)strlcpy(locbuf + 1, p, len - 1); locfile = locbuf; - } else if ((strcmp(locfile, "-") != 0) && *locfile != '|') { + } else if (locfile != locbuf) { if ((locbuf = globulize(locfile)) == NULL || !confirm("output to local-file:", locbuf)) { code = -1; @@ -1920,7 +1919,7 @@ setcase(int argc, char *argv[]) * convert the given name to lower case if it's all upper case, into * a static buffer which is returned to the caller */ -static const char * +static char * docase(char *dst, size_t dlen, const char *src) { size_t i; @@ -1973,7 +1972,14 @@ setntrans(int argc, char *argv[]) (void)strlcpy(ntout, argv[2], sizeof(ntout)); } -static const char * +#define ADDC(x) \ + do { \ + *cp2++ = x; \ + if (cp2 - dst >= (ptrdiff_t)(dlen - 1)) \ + goto out; \ + } while (0) + +static char * dotrans(char *dst, size_t dlen, const char *src) { const char *cp1; @@ -1988,15 +1994,13 @@ dotrans(char *dst, size_t dlen, const ch if (*cp1 == ntin[i]) { found++; if (i < ostop) { - *cp2++ = ntout[i]; - if (cp2 - dst >= (ptrdiff_t)(dlen - 1)) - goto out; + ADDC(ntout[i]); } break; } } if (!found) { - *cp2++ = *cp1; + ADDC(*cp1); } } out: @@ -2037,8 +2041,8 @@ setnmap(int argc, char *argv[]) (void)strlcpy(mapout, cp, MAXPATHLEN); } -static const char * -domap(char *dst, size_t dlen __unused, const char *src) +static char * +domap(char *dst, size_t dlen, const char *src) { const char *cp1 = src; char *cp2 = mapin; @@ -2093,7 +2097,7 @@ domap(char *dst, size_t dlen __unused, c switch (*cp1) { case '\\': if (*(cp1 + 1)) { - *cp2++ = *++cp1; + ADDC(*++cp1); } break; case '[': @@ -2104,7 +2108,7 @@ LOOP: const char *cp3 = src; while (*cp3) { - *cp2++ = *cp3++; + ADDC(*cp3++); } match = 1; } @@ -2112,7 +2116,7 @@ LOOP: const char *cp3 = tp[toknum]; while (cp3 != te[toknum]) { - *cp2++ = *cp3++; + ADDC(*cp3++); } match = 1; } @@ -2129,7 +2133,7 @@ LOOP: const char *cp3 = src; while (*cp3) { - *cp2++ = *cp3++; + ADDC(*cp3++); } } else if (toks[toknum = @@ -2138,19 +2142,16 @@ LOOP: while (cp3 != te[toknum]) { - *cp2++ = *cp3++; + ADDC(*cp3++); } } } else if (*cp1) { - *cp2++ = *cp1++; + ADDC(*cp1++); } } if (!*cp1) { - fputs( - "nmap: unbalanced brackets.\n", - ttyout); - return (src); + goto unbalanced; } match = 1; cp1--; @@ -2162,10 +2163,7 @@ LOOP: } } if (!*cp1) { - fputs( - "nmap: unbalanced brackets.\n", - ttyout); - return (src); + goto unbalanced; } break; } @@ -2185,27 +2183,34 @@ LOOP: const char *cp3 = src; while (*cp3) { - *cp2++ = *cp3++; + ADDC(*cp3++); } } else if (toks[toknum = *cp1 - '1']) { const char *cp3 = tp[toknum]; while (cp3 != te[toknum]) { - *cp2++ = *cp3++; + ADDC(*cp3++); } } break; } /* FALLTHROUGH */ default: - *cp2++ = *cp1; + ADDC(*cp1); break; } cp1++; } +out: *cp2 = '\0'; - return *dst ? dst : src; + if (!*dst) + strlcpy(dst, src, dlen); + return dst; +unbalanced: + fputs("nmap: unbalanced brackets.\n", ttyout); + *dst = '\0'; + goto out; } void Index: src/usr.bin/ftp/extern.h diff -u src/usr.bin/ftp/extern.h:1.82.10.1 src/usr.bin/ftp/extern.h:1.82.10.2 --- src/usr.bin/ftp/extern.h:1.82.10.1 Tue May 16 16:16:00 2023 +++ src/usr.bin/ftp/extern.h Mon Dec 2 10:19:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.82.10.1 2023/05/16 16:16:00 martin Exp $ */ +/* $NetBSD: extern.h,v 1.82.10.2 2024/12/02 10:19:39 martin Exp $ */ /*- * Copyright (c) 1996-2023 The NetBSD Foundation, Inc. @@ -137,7 +137,7 @@ char *getoptionvalue(const char *); void getremoteinfo(void); int getreply(int); char *globulize(const char *); -char *gunique(const char *); +char *gunique(char *); void help(int, char **); char *hookup(const char *, const char *); void idlecmd(int, char **); @@ -176,7 +176,7 @@ void quit(int, char **); void justquit(void) __dead; void quote(int, char **); void quote1(const char *, int, char **); -void recvrequest(const char *, const char *, const char *, +void recvrequest(const char *, char *, const char *, const char *, int, int); void reget(int, char **); char *remglob(char **, int, const char **); Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.235.2.3 src/usr.bin/ftp/fetch.c:1.235.2.4 --- src/usr.bin/ftp/fetch.c:1.235.2.3 Sun Oct 13 16:06:36 2024 +++ src/usr.bin/ftp/fetch.c Mon Dec 2 10:19:39 2024 @@ -1,7 +1,7 @@ -/* $NetBSD: fetch.c,v 1.235.2.3 2024/10/13 16:06:36 martin Exp $ */ +/* $NetBSD: fetch.c,v 1.235.2.4 2024/12/02 10:19:39 martin Exp $ */ /*- - * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2024 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.235.2.3 2024/10/13 16:06:36 martin Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.235.2.4 2024/12/02 10:19:39 martin Exp $"); #endif /* not lint */ /* @@ -1861,6 +1861,11 @@ chunkerror: } if (bytes > 0) ptransfer(0); + + /* fail if short transfer when filesize is known */ + if (filesize >= 0 && (bytes + restart_point < filesize)) + goto cleanup_fetch_url; + bytes = 0; rval = 0; Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.147.2.6 src/usr.bin/ftp/ftp.1:1.147.2.7 --- src/usr.bin/ftp/ftp.1:1.147.2.6 Mon Dec 2 09:05:18 2024 +++ src/usr.bin/ftp/ftp.1 Mon Dec 2 10:19:39 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.147.2.6 2024/12/02 09:05:18 martin Exp $ +.\" $NetBSD: ftp.1,v 1.147.2.7 2024/12/02 10:19:39 martin Exp $ .\" .\" Copyright (c) 1996-2024 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -57,7 +57,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd September 30, 2024 +.Dd November 29, 2024 .Dt FTP 1 .Os .Sh NAME @@ -65,7 +65,7 @@ .Nd Internet file transfer program .Sh SYNOPSIS .Nm -.Op Fl 46AadefginpRtVv\&? +.Op Fl 46AadefginpRtVv .Op Fl b Ar bufsize .Op Fl H Ar header .Op Fl N Ar netrc @@ -158,6 +158,8 @@ .Bk -words .Fl u Ar url Ar .Ek +.Nm +.Fl \&? .Sh DESCRIPTION .Nm is the user interface to the Internet standard File Transfer Protocol. @@ -205,7 +207,8 @@ Causes to bypass normal login procedure, and use an anonymous login instead. .It Fl b Ar bufsize Change the input buffer size to -.Ar bufsize . +.Ar bufsize +bytes. The default .Ar bufsize is @@ -300,9 +303,9 @@ Quit if the connection has stalled for seconds. .It Fl R Restart all non-proxied auto-fetches. -.It Fl r Ar wait +.It Fl r Ar retry Retry the connection attempt if it failed, pausing for -.Ar wait +.Ar retry seconds. .It Fl s Ar srcaddr Uses @@ -358,7 +361,8 @@ to show all responses from the remote se as report on data transfer statistics. .It Fl x Ar xfersize Set the size of the socket send and receive buffers to -.Ar xfersize . +.Ar xfersize +bytes. Refer to .Ic xferbuf for more information. Index: src/usr.bin/ftp/ftp.c diff -u src/usr.bin/ftp/ftp.c:1.174.2.2 src/usr.bin/ftp/ftp.c:1.174.2.3 --- src/usr.bin/ftp/ftp.c:1.174.2.2 Sun Oct 13 16:06:36 2024 +++ src/usr.bin/ftp/ftp.c Mon Dec 2 10:19:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.174.2.2 2024/10/13 16:06:36 martin Exp $ */ +/* $NetBSD: ftp.c,v 1.174.2.3 2024/12/02 10:19:39 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.174.2.2 2024/10/13 16:06:36 martin Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.174.2.3 2024/12/02 10:19:39 martin Exp $"); #endif #endif /* not lint */ @@ -925,7 +925,7 @@ sendrequest(const char *cmd, const char } void -recvrequest(const char *cmd, const char *volatile local, const char *remote, +recvrequest(const char *cmd, char *volatile local, const char *remote, const char *lmode, int printnames, int ignorespecial) { FILE *volatile fout; @@ -2037,7 +2037,7 @@ reset(int argc, char *argv[]) } char * -gunique(const char *local) +gunique(char *local) { static char new[MAXPATHLEN]; char *cp = strrchr(local, '/'); Index: src/usr.bin/ftp/main.c diff -u src/usr.bin/ftp/main.c:1.128.2.2 src/usr.bin/ftp/main.c:1.128.2.3 --- src/usr.bin/ftp/main.c:1.128.2.2 Sun Oct 13 16:06:36 2024 +++ src/usr.bin/ftp/main.c Mon Dec 2 10:19:39 2024 @@ -1,7 +1,7 @@ -/* $NetBSD: main.c,v 1.128.2.2 2024/10/13 16:06:36 martin Exp $ */ +/* $NetBSD: main.c,v 1.128.2.3 2024/12/02 10:19:39 martin Exp $ */ /*- - * Copyright (c) 1996-2023 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2024 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -98,7 +98,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19 #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: main.c,v 1.128.2.2 2024/10/13 16:06:36 martin Exp $"); +__RCSID("$NetBSD: main.c,v 1.128.2.3 2024/12/02 10:19:39 martin Exp $"); #endif #endif /* not lint */ @@ -271,7 +271,7 @@ main(int volatile argc, char **volatile } SLIST_INIT(&custom_headers); - while ((ch = getopt(argc, argv, ":46Aab:defgH:inN:o:pP:q:r:Rs:tT:u:vVx:")) != -1) { + while ((ch = getopt(argc, argv, ":46Aab:defgH:iN:no:P:pq:Rr:s:T:tu:Vvx:")) != -1) { switch (ch) { case '4': family = AF_INET; @@ -329,10 +329,6 @@ main(int volatile argc, char **volatile interactive = 0; break; - case 'n': - autologin = 0; - break; - case 'N': if (strlcpy(netrc, optarg, sizeof(netrc)) >= sizeof(netrc)) @@ -340,45 +336,45 @@ main(int volatile argc, char **volatile strerror(ENAMETOOLONG)); break; + case 'n': + autologin = 0; + break; + case 'o': outfile = ftp_strdup(optarg); if (strcmp(outfile, "-") == 0) ttyout = stderr; break; + case 'P': + ftpport = optarg; + break; + case 'p': passivemode = 1; activefallback = 0; break; - case 'P': - ftpport = optarg; - break; - case 'q': quit_time = (int)strtol(optarg, &ep, 10); if (quit_time < 1 || *ep != '\0') errx(1, "Bad quit value: %s", optarg); break; + case 'R': + restartautofetch = 1; + break; + case 'r': retry_connect = (int)strtol(optarg, &ep, 10); if (retry_connect < 1 || *ep != '\0') errx(1, "Bad retry value: %s", optarg); break; - case 'R': - restartautofetch = 1; - break; - case 's': src_addr = optarg; break; - case 't': - trace = 1; - break; - case 'T': { int targc; @@ -408,6 +404,10 @@ main(int volatile argc, char **volatile break; } + case 't': + trace = 1; + break; + case 'u': { isupload = 1; @@ -417,14 +417,14 @@ main(int volatile argc, char **volatile break; } - case 'v': - progress = verbose = 1; - break; - case 'V': progress = verbose = 0; break; + case 'v': + progress = verbose = 1; + break; + case 'x': sndbuf_size = strsuftoi(optarg); if (sndbuf_size < 1) @@ -1080,8 +1080,8 @@ synopsis(FILE * stream) const char * progname = getprogname(); fprintf(stream, -"usage: %s [-46AadefginpRtVv] [-H HEADER] [-N NETRC] [-o OUTPUT] [-P PORT]\n" -" [-q QUITTIME] [-r RETRY] [-s SRCADDR] [-T DIR,MAX[,INC]]\n" +"usage: %s [-46AadefginpRtVv] [-b BUFSIZE] [-H HEADER] [-N NETRC] [-o OUTPUT]\n" +" [-P PORT] [-q QUITTIME] [-r RETRY] [-s SRCADDR] [-T DIR,MAX[,INC]]\n" " [-x XFERSIZE]\n" " [[USER@]HOST [PORT]]\n" " [[USER@]HOST:[PATH][/]]\n" @@ -1107,11 +1107,13 @@ usage_help(void) " -6 Only use IPv6 addresses\n" " -A Force active mode\n" " -a Use anonymous login\n" -" -b BUFLEN Use BUFLEN bytes for fetch buffer\n" +" -b BUFSIZE Use BUFSIZE bytes for fetch buffer\n" " -d Enable debugging\n" " -e Disable command-line editing\n" " -f Force cache reload for FTP or HTTP proxy transfers\n" " -g Disable file name globbing\n" +" -H HEADER Add custom HTTP header HEADER for HTTP transfers;\n" +" may be repeated for additional headers\n" " -i Disable interactive prompt during multiple file transfers\n" " -N NETRC Use NETRC instead of ~/.netrc\n" " -n Disable auto-login\n" @@ -1121,15 +1123,15 @@ usage_help(void) " -q QUITTIME Quit if connection stalls for QUITTIME seconds\n" " -R Restart non-proxy auto-fetch\n" " -r RETRY Retry failed connection attempts after RETRY seconds\n" -" -s SRCADDR Use source address SRCADDR\n" -" -t Enable packet tracing\n" +" -s SRCADDR Use IP source address SRCADDR\n" " -T DIR,MAX[,INC]\n" -" Set maximum transfer rate for direction DIR to MAX bytes/s,\n" -" with optional increment INC bytes/s\n" +" Set maximum transfer rate for direction DIR (all, get, or put)\n" +" to MAX bytes/s, with optional increment INC bytes/s\n" +" -t Enable packet tracing\n" " -u URL URL to upload file arguments to\n" " -V Disable verbose and progress\n" " -v Enable verbose and progress\n" -" -x XFERSIZE Set socket send and receive size to XFERSIZE\n" +" -x XFERSIZE Set socket send and receive size to XFERSIZE bytes\n" " -? Display this help and exit\n" ); #endif Index: src/usr.bin/ftp/progressbar.c diff -u src/usr.bin/ftp/progressbar.c:1.24.6.1 src/usr.bin/ftp/progressbar.c:1.24.6.2 --- src/usr.bin/ftp/progressbar.c:1.24.6.1 Sun Oct 13 16:06:36 2024 +++ src/usr.bin/ftp/progressbar.c Mon Dec 2 10:19:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: progressbar.c,v 1.24.6.1 2024/10/13 16:06:36 martin Exp $ */ +/* $NetBSD: progressbar.c,v 1.24.6.2 2024/12/02 10:19:39 martin Exp $ */ /*- * Copyright (c) 1997-2024 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.24.6.1 2024/10/13 16:06:36 martin Exp $"); +__RCSID("$NetBSD: progressbar.c,v 1.24.6.2 2024/12/02 10:19:39 martin Exp $"); #endif /* not lint */ /* @@ -123,12 +123,12 @@ static struct timeval lastupdate; void progressmeter(int flag) { - static off_t lastsize; - off_t cursize; + static uint64_t lastsize; + uint64_t cursize; struct timeval now, wait; #ifndef NO_PROGRESS struct timeval td; - off_t abbrevsize, bytespersec; + uint64_t abbrevsize, bytespersec; double elapsed; int ratio, i, remaining, barlength; @@ -261,7 +261,7 @@ progressmeter(int flag) suffixes[i]); if (filesize > 0) { - if (bytes <= 0 || elapsed <= 0.0 || cursize > filesize) { + if (bytes <= 0 || elapsed <= 0.0 || cursize > (uint64_t)filesize) { len += snprintf(buf + len, BUFLEFT, " --:-- ETA"); } else if (wait.tv_sec >= STALLTIME) { len += snprintf(buf + len, BUFLEFT, " - stalled -"); Index: src/usr.bin/ftp/ruserpass.c diff -u src/usr.bin/ftp/ruserpass.c:1.33.86.1 src/usr.bin/ftp/ruserpass.c:1.33.86.2 --- src/usr.bin/ftp/ruserpass.c:1.33.86.1 Sun Oct 13 16:06:36 2024 +++ src/usr.bin/ftp/ruserpass.c Mon Dec 2 10:19:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ruserpass.c,v 1.33.86.1 2024/10/13 16:06:36 martin Exp $ */ +/* $NetBSD: ruserpass.c,v 1.33.86.2 2024/12/02 10:19:39 martin Exp $ */ /* * Copyright (c) 1985, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: ruserpass.c,v 1.33.86.1 2024/10/13 16:06:36 martin Exp $"); +__RCSID("$NetBSD: ruserpass.c,v 1.33.86.2 2024/12/02 10:19:39 martin Exp $"); #endif #endif /* not lint */ @@ -79,6 +79,20 @@ static struct toktab { { NULL, 0 } }; +static int +match_host_domain(const char *host, const char *domain, const char *tokv) +{ + const char *tmp; + + if (strcasecmp(host, tokval) == 0) + return 1; + + return (tmp = strchr(host, '.')) != NULL && + strcasecmp(tmp, domain) == 0 && + strncasecmp(host, tokv, tmp - host) == 0 && + tokv[tmp - host] == '\0'; +} + int ruserpass(const char *host, char **aname, char **apass, char **aacct) { @@ -119,19 +133,9 @@ ruserpass(const char *host, char **aname * or official hostname. Also allow match of * incompletely-specified host in local domain. */ - if (strcasecmp(host, tokval) == 0) - goto match; - if (strcasecmp(hostname, tokval) == 0) - goto match; - if ((tmp = strchr(hostname, '.')) != NULL && - strcasecmp(tmp, mydomain) == 0 && - strncasecmp(hostname, tokval, tmp-hostname) == 0 && - tokval[tmp - hostname] == '\0') + if (match_host_domain(hostname, mydomain, tokval)) goto match; - if ((tmp = strchr(host, '.')) != NULL && - strcasecmp(tmp, mydomain) == 0 && - strncasecmp(host, tokval, tmp - host) == 0 && - tokval[tmp - host] == '\0') + if (match_host_domain(host, mydomain, tokval)) goto match; continue; } Index: src/usr.bin/ftp/util.c diff -u src/usr.bin/ftp/util.c:1.164.2.3 src/usr.bin/ftp/util.c:1.164.2.4 --- src/usr.bin/ftp/util.c:1.164.2.3 Sun Oct 13 16:06:36 2024 +++ src/usr.bin/ftp/util.c Mon Dec 2 10:19:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.164.2.3 2024/10/13 16:06:36 martin Exp $ */ +/* $NetBSD: util.c,v 1.164.2.4 2024/12/02 10:19:39 martin Exp $ */ /*- * Copyright (c) 1997-2023 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: util.c,v 1.164.2.3 2024/10/13 16:06:36 martin Exp $"); +__RCSID("$NetBSD: util.c,v 1.164.2.4 2024/12/02 10:19:39 martin Exp $"); #endif /* not lint */ /* @@ -209,7 +209,7 @@ getremoteinfo(void) (int)os_len, reply_string + 4); } /* - * Decide whether we should default to bninary. + * Decide whether we should default to binary. * Traditionally checked for "215 UNIX Type: L8", but * some printers report "Linux" ! so be more forgiving. * In reality we probably almost never want text any more. Index: src/usr.bin/ftp/version.h diff -u src/usr.bin/ftp/version.h:1.95.2.2 src/usr.bin/ftp/version.h:1.95.2.3 --- src/usr.bin/ftp/version.h:1.95.2.2 Tue May 16 16:26:03 2023 +++ src/usr.bin/ftp/version.h Mon Dec 2 10:19:39 2024 @@ -1,7 +1,7 @@ -/* $NetBSD: version.h,v 1.95.2.2 2023/05/16 16:26:03 martin Exp $ */ +/* $NetBSD: version.h,v 1.95.2.3 2024/12/02 10:19:39 martin Exp $ */ /*- - * Copyright (c) 1999-2023 The NetBSD Foundation, Inc. + * Copyright (c) 1999-2024 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -34,5 +34,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20230505" +#define FTP_VERSION "20241129" #endif