CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Mon Sep 12 17:06:56 UTC 2022 Modified Files: src/usr.bin/ftp [netbsd-9]: Makefile cmds.c fetch.c ftp.1 ftp.c ftp_var.h main.c progressbar.c progressbar.h ssl.c ssl.h util.c version.h Log Message: Catch up to current, requested by christos in ticket #1523 usr.bin/ftp/Makefileup to 1.39 usr.bin/ftp/fetch.c up to 1.235 usr.bin/ftp/ftp.1 up to 1.147 usr.bin/ftp/ftp_var.h up to 1.86 usr.bin/ftp/main.c up to 1.128 usr.bin/ftp/ssl.c up to 1.12 usr.bin/ftp/util.c up to 1.164 usr.bin/ftp/version.h up to 1.94 PR 57003: Support relative redirects. To generate a diff of this commit: cvs rdiff -u -r1.37.12.3 -r1.37.12.4 src/usr.bin/ftp/Makefile cvs rdiff -u -r1.140.2.1 -r1.140.2.2 src/usr.bin/ftp/cmds.c cvs rdiff -u -r1.231.2.4 -r1.231.2.5 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.136.8.3 -r1.136.8.4 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.168.2.6 -r1.168.2.7 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.85.6.2 -r1.85.6.3 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.126.2.2 -r1.126.2.3 src/usr.bin/ftp/main.c cvs rdiff -u -r1.23.2.1 -r1.23.2.2 src/usr.bin/ftp/progressbar.c cvs rdiff -u -r1.8.48.1 -r1.8.48.2 src/usr.bin/ftp/progressbar.h cvs rdiff -u -r1.8.2.4 -r1.8.2.5 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/usr.bin/ftp/ssl.h cvs rdiff -u -r1.160.2.3 -r1.160.2.4 src/usr.bin/ftp/util.c cvs rdiff -u -r1.87.18.5 -r1.87.18.6 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.
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Mon Sep 12 17:06:56 UTC 2022 Modified Files: src/usr.bin/ftp [netbsd-9]: Makefile cmds.c fetch.c ftp.1 ftp.c ftp_var.h main.c progressbar.c progressbar.h ssl.c ssl.h util.c version.h Log Message: Catch up to current, requested by christos in ticket #1523 usr.bin/ftp/Makefileup to 1.39 usr.bin/ftp/fetch.c up to 1.235 usr.bin/ftp/ftp.1 up to 1.147 usr.bin/ftp/ftp_var.h up to 1.86 usr.bin/ftp/main.c up to 1.128 usr.bin/ftp/ssl.c up to 1.12 usr.bin/ftp/util.c up to 1.164 usr.bin/ftp/version.h up to 1.94 PR 57003: Support relative redirects. To generate a diff of this commit: cvs rdiff -u -r1.37.12.3 -r1.37.12.4 src/usr.bin/ftp/Makefile cvs rdiff -u -r1.140.2.1 -r1.140.2.2 src/usr.bin/ftp/cmds.c cvs rdiff -u -r1.231.2.4 -r1.231.2.5 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.136.8.3 -r1.136.8.4 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.168.2.6 -r1.168.2.7 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.85.6.2 -r1.85.6.3 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.126.2.2 -r1.126.2.3 src/usr.bin/ftp/main.c cvs rdiff -u -r1.23.2.1 -r1.23.2.2 src/usr.bin/ftp/progressbar.c cvs rdiff -u -r1.8.48.1 -r1.8.48.2 src/usr.bin/ftp/progressbar.h cvs rdiff -u -r1.8.2.4 -r1.8.2.5 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/usr.bin/ftp/ssl.h cvs rdiff -u -r1.160.2.3 -r1.160.2.4 src/usr.bin/ftp/util.c cvs rdiff -u -r1.87.18.5 -r1.87.18.6 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/Makefile diff -u src/usr.bin/ftp/Makefile:1.37.12.3 src/usr.bin/ftp/Makefile:1.37.12.4 --- src/usr.bin/ftp/Makefile:1.37.12.3 Mon Sep 12 15:02:47 2022 +++ src/usr.bin/ftp/Makefile Mon Sep 12 17:06:56 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.37.12.3 2022/09/12 15:02:47 martin Exp $ +# $NetBSD: Makefile,v 1.37.12.4 2022/09/12 17:06:56 martin Exp $ # from: @(#)Makefile 8.2 (Berkeley) 4/3/94 .include @@ -31,4 +31,6 @@ CPPFLAGS+= -DINET6 cmds.o fetch.o: version.h main.o: ftp_var.h +CWARNFLAGS.gcc+= ${GCC_NO_FORMAT_OVERFLOW} + .include Index: src/usr.bin/ftp/cmds.c diff -u src/usr.bin/ftp/cmds.c:1.140.2.1 src/usr.bin/ftp/cmds.c:1.140.2.2 --- src/usr.bin/ftp/cmds.c:1.140.2.1 Mon Jun 14 11:52:52 2021 +++ src/usr.bin/ftp/cmds.c Mon Sep 12 17:06:56 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cmds.c,v 1.140.2.1 2021/06/14 11:52:52 martin Exp $ */ +/* $NetBSD: cmds.c,v 1.140.2.2 2022/09/12 17:06:56 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.140.2.1 2021/06/14 11:52:52 martin Exp $"); +__RCSID("$NetBSD: cmds.c,v 1.140.2.2 2022/09/12 17:06:56 martin Exp $"); #endif #endif /* not lint */ Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.231.2.4 src/usr.bin/ftp/fetch.c:1.231.2.5 --- src/usr.bin/ftp/fetch.c:1.231.2.4 Mon Sep 12 15:02:47 2022 +++ src/usr.bin/ftp/fetch.c Mon Sep 12 17:06:56 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.231.2.4 2022/09/12 15:02:47 martin Exp $ */ +/* $NetBSD: fetch.c,v 1.231.2.5 2022/09/12 17:06:56 martin Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.231.2.4 2022/09/12 15:02:47 martin Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.231.2.5 2022/09/12 17:06:56 martin Exp $"); #endif /* not lint */ /* @@ -106,12 +106,13 @@ __dead static void timeouthttp(int); static int auth_url(const char *, char **, const struct authinfo *); static void base64_encode(const unsigned char *, size_t, unsigned char *); #endif -static int go_fetch(const char *); +static int go_fetch(const char *, struct urlinfo *); static int fetch_ftp(const char *); -static int fetch_url(const char *, const char *, char *, char *); +static int fetch_url(const char *, const char *, char *, char *, +struct urlinfo *); static const char *match_token(const char **, const char *); static int parse_url(const char *, const char *, struct urlinfo *, -struct authinfo *); +struct authinfo *, struct urlinfo *); static void url_decode(char *); static void freeauthinfo(struct authinfo *); static void freeurlinfo(struct urlinfo *); @@ -274,7 +275,7 @@ auth_url(const char *challenge, char **r scheme = "Basic"; /* only support Basic authentication */ gotpass = NULL; - DPRINTF("auth_url: challenge `%s'\n", challenge); + DPRINTF("%s: challenge `%s'\n", __func__, challenge); if (! match_token(&cp, scheme)) { warnx("Unsupported authentication challenge `%s'", @@ -336,7 +3
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Mon Sep 12 15:02:47 UTC 2022 Modified Files: src/usr.bin/ftp [netbsd-9]: Makefile fetch.c ftp.1 ftp_var.h main.c ssl.c util.c version.h Log Message: Back out ticket #1523 for now - trust anchor validation is not solved. To generate a diff of this commit: cvs rdiff -u -r1.37.12.2 -r1.37.12.3 src/usr.bin/ftp/Makefile cvs rdiff -u -r1.231.2.3 -r1.231.2.4 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.136.8.2 -r1.136.8.3 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.85.6.1 -r1.85.6.2 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.126.2.1 -r1.126.2.2 src/usr.bin/ftp/main.c cvs rdiff -u -r1.8.2.3 -r1.8.2.4 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.160.2.2 -r1.160.2.3 src/usr.bin/ftp/util.c cvs rdiff -u -r1.87.18.4 -r1.87.18.5 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/Makefile diff -u src/usr.bin/ftp/Makefile:1.37.12.2 src/usr.bin/ftp/Makefile:1.37.12.3 --- src/usr.bin/ftp/Makefile:1.37.12.2 Mon Sep 12 14:42:55 2022 +++ src/usr.bin/ftp/Makefile Mon Sep 12 15:02:47 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.37.12.2 2022/09/12 14:42:55 martin Exp $ +# $NetBSD: Makefile,v 1.37.12.3 2022/09/12 15:02:47 martin Exp $ # from: @(#)Makefile 8.2 (Berkeley) 4/3/94 .include @@ -31,6 +31,4 @@ CPPFLAGS+= -DINET6 cmds.o fetch.o: version.h main.o: ftp_var.h -CWARNFLAGS.gcc+= ${GCC_NO_FORMAT_OVERFLOW} - .include Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.231.2.3 src/usr.bin/ftp/fetch.c:1.231.2.4 --- src/usr.bin/ftp/fetch.c:1.231.2.3 Mon Sep 12 14:42:55 2022 +++ src/usr.bin/ftp/fetch.c Mon Sep 12 15:02:47 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.231.2.3 2022/09/12 14:42:55 martin Exp $ */ +/* $NetBSD: fetch.c,v 1.231.2.4 2022/09/12 15:02:47 martin Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.231.2.3 2022/09/12 14:42:55 martin Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.231.2.4 2022/09/12 15:02:47 martin Exp $"); #endif /* not lint */ /* @@ -106,13 +106,12 @@ __dead static void timeouthttp(int); static int auth_url(const char *, char **, const struct authinfo *); static void base64_encode(const unsigned char *, size_t, unsigned char *); #endif -static int go_fetch(const char *, struct urlinfo *); +static int go_fetch(const char *); static int fetch_ftp(const char *); -static int fetch_url(const char *, const char *, char *, char *, -struct urlinfo *); +static int fetch_url(const char *, const char *, char *, char *); static const char *match_token(const char **, const char *); static int parse_url(const char *, const char *, struct urlinfo *, -struct authinfo *, struct urlinfo *); +struct authinfo *); static void url_decode(char *); static void freeauthinfo(struct authinfo *); static void freeurlinfo(struct urlinfo *); @@ -275,7 +274,7 @@ auth_url(const char *challenge, char **r scheme = "Basic"; /* only support Basic authentication */ gotpass = NULL; - DPRINTF("%s: challenge `%s'\n", __func__, challenge); + DPRINTF("auth_url: challenge `%s'\n", challenge); if (! match_token(&cp, scheme)) { warnx("Unsupported authentication challenge `%s'", @@ -337,7 +336,7 @@ auth_url(const char *challenge, char **r *response = ftp_malloc(rlen); (void)strlcpy(*response, scheme, rlen); len = strlcat(*response, " ", rlen); - /* use `clen - 1' to not encode the trailing NUL */ + /* use `clen - 1' to not encode the trailing NUL */ base64_encode((unsigned char *)clear, clen - 1, (unsigned char *)*response + len); memset(clear, 0, clen); @@ -368,7 +367,7 @@ base64_encode(const unsigned char *clear | ((clear[i + 1] >> 4) & 0x0f)]; *(cp++) = enc[((clear[i + 1] << 2) & 0x3c) | ((clear[i + 2] >> 6) & 0x03)]; - *(cp++) = enc[((clear[i + 2] ) & 0x3f)]; + *(cp++) = enc[((clear[i + 2] ) & 0x3f)]; } *cp = '\0'; while (i-- > len) @@ -401,42 +400,6 @@ url_decode(char *url) *q = '\0'; } -static const char * -get_port(const struct urlinfo *ui) -{ - - switch(ui->utype) { - case HTTP_URL_T: - return httpport; - case FTP_URL_T: - return ftpport; - case FILE_URL_T: - return ""; -#ifdef WITH_SSL - case HTTPS_URL_T: - return httpsport; -#endif - default: - return NULL; - } -} - -static int -use_relative(const struct urlinfo *ui) -{ - if (ui == NULL) - return 0; - switch (ui->utype) { - case HTTP_URL_T: - case FILE_URL_T: -#ifdef WITH_SSL - case HTTPS_URL_T: -#endif - return 1; - default: - return 0; - } -} /* * Parse URL of form (per RFC 3986): @@ -472,7 +435,7 @@ use_relative(const struct urlinfo *ui) static int parse_url(const char *url, const char *desc, struct urlinfo *ui, -struct authinfo *auth, struct urlinfo *rui) +struct authinfo *auth) { const char *origurl, *tport; char *cp, *ep, *thost; @@ -483,26 +
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Mon Sep 12 15:02:47 UTC 2022 Modified Files: src/usr.bin/ftp [netbsd-9]: Makefile fetch.c ftp.1 ftp_var.h main.c ssl.c util.c version.h Log Message: Back out ticket #1523 for now - trust anchor validation is not solved. To generate a diff of this commit: cvs rdiff -u -r1.37.12.2 -r1.37.12.3 src/usr.bin/ftp/Makefile cvs rdiff -u -r1.231.2.3 -r1.231.2.4 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.136.8.2 -r1.136.8.3 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.85.6.1 -r1.85.6.2 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.126.2.1 -r1.126.2.2 src/usr.bin/ftp/main.c cvs rdiff -u -r1.8.2.3 -r1.8.2.4 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.160.2.2 -r1.160.2.3 src/usr.bin/ftp/util.c cvs rdiff -u -r1.87.18.4 -r1.87.18.5 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.
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Mon Sep 12 14:42:56 UTC 2022 Modified Files: src/usr.bin/ftp [netbsd-9]: Makefile fetch.c ftp.1 ftp_var.h main.c ssl.c util.c version.h Log Message: Catch up to current, requested by christos in ticket #1523 usr.bin/ftp/Makefileup to 1.39 usr.bin/ftp/fetch.c up to 1.235 usr.bin/ftp/ftp.1 up to 1.147 usr.bin/ftp/ftp_var.h up to 1.86 usr.bin/ftp/main.c up to 1.128 usr.bin/ftp/ssl.c up to 1.11 usr.bin/ftp/util.c up to 1.164 usr.bin/ftp/version.h up to 1.94 PR 57003: Support relative redirects. To generate a diff of this commit: cvs rdiff -u -r1.37.12.1 -r1.37.12.2 src/usr.bin/ftp/Makefile cvs rdiff -u -r1.231.2.2 -r1.231.2.3 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.136.8.1 -r1.136.8.2 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.85 -r1.85.6.1 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.126 -r1.126.2.1 src/usr.bin/ftp/main.c cvs rdiff -u -r1.8.2.2 -r1.8.2.3 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.160.2.1 -r1.160.2.2 src/usr.bin/ftp/util.c cvs rdiff -u -r1.87.18.3 -r1.87.18.4 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/Makefile diff -u src/usr.bin/ftp/Makefile:1.37.12.1 src/usr.bin/ftp/Makefile:1.37.12.2 --- src/usr.bin/ftp/Makefile:1.37.12.1 Mon Jun 14 11:57:39 2021 +++ src/usr.bin/ftp/Makefile Mon Sep 12 14:42:55 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.37.12.1 2021/06/14 11:57:39 martin Exp $ +# $NetBSD: Makefile,v 1.37.12.2 2022/09/12 14:42:55 martin Exp $ # from: @(#)Makefile 8.2 (Berkeley) 4/3/94 .include @@ -31,4 +31,6 @@ CPPFLAGS+= -DINET6 cmds.o fetch.o: version.h main.o: ftp_var.h +CWARNFLAGS.gcc+= ${GCC_NO_FORMAT_OVERFLOW} + .include Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.231.2.2 src/usr.bin/ftp/fetch.c:1.231.2.3 --- src/usr.bin/ftp/fetch.c:1.231.2.2 Sun Oct 24 10:13:40 2021 +++ src/usr.bin/ftp/fetch.c Mon Sep 12 14:42:55 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.231.2.2 2021/10/24 10:13:40 martin Exp $ */ +/* $NetBSD: fetch.c,v 1.231.2.3 2022/09/12 14:42:55 martin Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.231.2.2 2021/10/24 10:13:40 martin Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.231.2.3 2022/09/12 14:42:55 martin Exp $"); #endif /* not lint */ /* @@ -106,12 +106,13 @@ __dead static void timeouthttp(int); static int auth_url(const char *, char **, const struct authinfo *); static void base64_encode(const unsigned char *, size_t, unsigned char *); #endif -static int go_fetch(const char *); +static int go_fetch(const char *, struct urlinfo *); static int fetch_ftp(const char *); -static int fetch_url(const char *, const char *, char *, char *); +static int fetch_url(const char *, const char *, char *, char *, +struct urlinfo *); static const char *match_token(const char **, const char *); static int parse_url(const char *, const char *, struct urlinfo *, -struct authinfo *); +struct authinfo *, struct urlinfo *); static void url_decode(char *); static void freeauthinfo(struct authinfo *); static void freeurlinfo(struct urlinfo *); @@ -274,7 +275,7 @@ auth_url(const char *challenge, char **r scheme = "Basic"; /* only support Basic authentication */ gotpass = NULL; - DPRINTF("auth_url: challenge `%s'\n", challenge); + DPRINTF("%s: challenge `%s'\n", __func__, challenge); if (! match_token(&cp, scheme)) { warnx("Unsupported authentication challenge `%s'", @@ -336,7 +337,7 @@ auth_url(const char *challenge, char **r *response = ftp_malloc(rlen); (void)strlcpy(*response, scheme, rlen); len = strlcat(*response, " ", rlen); - /* use `clen - 1' to not encode the trailing NUL */ + /* use `clen - 1' to not encode the trailing NUL */ base64_encode((unsigned char *)clear, clen - 1, (unsigned char *)*response + len); memset(clear, 0, clen); @@ -367,7 +368,7 @@ base64_encode(const unsigned char *clear | ((clear[i + 1] >> 4) & 0x0f)]; *(cp++) = enc[((clear[i + 1] << 2) & 0x3c) | ((clear[i + 2] >> 6) & 0x03)]; - *(cp++) = enc[((clear[i + 2] ) & 0x3f)]; + *(cp++) = enc[((clear[i + 2] ) & 0x3f)]; } *cp = '\0'; while (i-- > len) @@ -400,6 +401,42 @@ url_decode(char *url) *q = '\0'; } +static const char * +get_port(const struct urlinfo *ui) +{ + + switch(ui->utype) { + case HTTP_URL_T: + return httpport; + case FTP_URL_T: + return ftpport; + case FILE_URL_T: + return ""; +#ifdef WITH_SSL + case HTTPS_URL_T: + return httpsport; +#endif + default: + return NULL; + } +} + +static i
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Mon Sep 12 14:42:56 UTC 2022 Modified Files: src/usr.bin/ftp [netbsd-9]: Makefile fetch.c ftp.1 ftp_var.h main.c ssl.c util.c version.h Log Message: Catch up to current, requested by christos in ticket #1523 usr.bin/ftp/Makefileup to 1.39 usr.bin/ftp/fetch.c up to 1.235 usr.bin/ftp/ftp.1 up to 1.147 usr.bin/ftp/ftp_var.h up to 1.86 usr.bin/ftp/main.c up to 1.128 usr.bin/ftp/ssl.c up to 1.11 usr.bin/ftp/util.c up to 1.164 usr.bin/ftp/version.h up to 1.94 PR 57003: Support relative redirects. To generate a diff of this commit: cvs rdiff -u -r1.37.12.1 -r1.37.12.2 src/usr.bin/ftp/Makefile cvs rdiff -u -r1.231.2.2 -r1.231.2.3 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.136.8.1 -r1.136.8.2 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.85 -r1.85.6.1 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.126 -r1.126.2.1 src/usr.bin/ftp/main.c cvs rdiff -u -r1.8.2.2 -r1.8.2.3 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.160.2.1 -r1.160.2.2 src/usr.bin/ftp/util.c cvs rdiff -u -r1.87.18.3 -r1.87.18.4 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.
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Sun Oct 24 10:18:02 UTC 2021 Modified Files: src/usr.bin/ftp [netbsd-9]: ftp.c Log Message: Pull up following revision(s) (requested by lukem in ticket #1367): usr.bin/ftp/ftp.c: revision 1.174 ftp: remove unnecessary variable assignments Remove assignment to error in initconn(); it's not tested anywhere after the initial use, so no need to set it before goto bad. (Looks like copypasta from the initial addition of the code in rev 1.48.) To generate a diff of this commit: cvs rdiff -u -r1.168.2.5 -r1.168.2.6 src/usr.bin/ftp/ftp.c 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.2.5 src/usr.bin/ftp/ftp.c:1.168.2.6 --- src/usr.bin/ftp/ftp.c:1.168.2.5 Sun Oct 24 10:16:05 2021 +++ src/usr.bin/ftp/ftp.c Sun Oct 24 10:18:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.168.2.5 2021/10/24 10:16:05 martin Exp $ */ +/* $NetBSD: ftp.c,v 1.168.2.6 2021/10/24 10:18:02 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.5 2021/10/24 10:16:05 martin Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.168.2.6 2021/10/24 10:18:02 martin Exp $"); #endif #endif /* not lint */ @@ -1381,13 +1381,11 @@ initconn(void) if (data_addr.su_family != AF_INET) { fputs( "Passive mode AF mismatch. Shouldn't happen!\n", ttyout); -error = 1; goto bad; } if (code / 10 == 22 && code != 227) { fputs("wrong server: return code must be 227\n", ttyout); -error = 1; goto bad; } error = sscanf(pasv, "%u,%u,%u,%u,%u,%u", @@ -1396,10 +1394,8 @@ initconn(void) if (error != 6) { fputs( "Passive mode address scan failure. Shouldn't happen!\n", ttyout); -error = 1; goto bad; } - error = 0; memset(&data_addr, 0, sizeof(data_addr)); data_addr.su_family = AF_INET; data_addr.su_len = sizeof(struct sockaddr_in); @@ -1416,7 +1412,6 @@ initconn(void) if (code / 10 == 22 && code != 228) { fputs("wrong server: return code must be 228\n", ttyout); -error = 1; goto bad; } switch (data_addr.su_family) { @@ -1429,17 +1424,14 @@ initconn(void) if (error != 9) { fputs( "Passive mode address scan failure. Shouldn't happen!\n", ttyout); - error = 1; goto bad; } if (af != 4 || hal != 4 || pal != 2) { fputs( "Passive mode AF mismatch. Shouldn't happen!\n", ttyout); - error = 1; goto bad; } -error = 0; memset(&data_addr, 0, sizeof(data_addr)); data_addr.su_family = AF_INET; data_addr.su_len = sizeof(struct sockaddr_in); @@ -1467,17 +1459,14 @@ initconn(void) if (error != 21) { fputs( "Passive mode address scan failure. Shouldn't happen!\n", ttyout); - error = 1; goto bad; } if (af != 6 || hal != 16 || pal != 2) { fputs( "Passive mode AF mismatch. Shouldn't happen!\n", ttyout); - error = 1; goto bad; } -error = 0; memset(&data_addr, 0, sizeof(data_addr)); data_addr.su_family = AF_INET6; data_addr.su_len = sizeof(struct sockaddr_in6); @@ -1500,7 +1489,8 @@ initconn(void) break; #endif default: -error = 1; +fputs("Unknown passive mode AF.\n", ttyout); +goto bad; } } else if (strcmp(pasvcmd, "EPSV") == 0) { char delim[4]; @@ -1509,20 +1499,17 @@ initconn(void) if (code / 10 == 22 && code != 229) { fputs("wrong server: return code must be 229\n", ttyout); -error = 1; goto bad; } if (sscanf(pasv, "%c%c%c%d%c", &delim[0], &delim[1], &delim[2], &port[1], &delim[3]) != 5) { fputs("parse error!\n", ttyout); -error = 1; goto bad; } if (delim[0] != delim[1] || delim[0] != delim[2] || delim[0] != delim[3]) { fputs("parse error!\n", ttyout); -error = 1; goto bad; } data_addr = hisctladdr;
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Sun Oct 24 10:18:02 UTC 2021 Modified Files: src/usr.bin/ftp [netbsd-9]: ftp.c Log Message: Pull up following revision(s) (requested by lukem in ticket #1367): usr.bin/ftp/ftp.c: revision 1.174 ftp: remove unnecessary variable assignments Remove assignment to error in initconn(); it's not tested anywhere after the initial use, so no need to set it before goto bad. (Looks like copypasta from the initial addition of the code in rev 1.48.) To generate a diff of this commit: cvs rdiff -u -r1.168.2.5 -r1.168.2.6 src/usr.bin/ftp/ftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Sun Oct 24 10:16:05 UTC 2021 Modified Files: src/usr.bin/ftp [netbsd-9]: ftp.c Log Message: Pull up following revision(s) (requested by lukem in ticket #1366): usr.bin/ftp/ftp.c: revision 1.173 ftp: validate address from PASV and LPSV response Fail if the server's response to PASV or LPSV contains an IP address that doesn't match that of the control connection. (EPSV already only uses the port portion of the server's response, per RFC 2428). Previously a hostile server could cause ftp to open a data connection elsewhere. Many other ftp implementations have had a similar change for many years, including those in popular browsers (before they deprecated FTP ...) Thanks to Simon Josefsson notifying me about https://lists.gnu.org/archive/html/bug-inetutils/2021-06/msg2.html To generate a diff of this commit: cvs rdiff -u -r1.168.2.4 -r1.168.2.5 src/usr.bin/ftp/ftp.c 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.2.4 src/usr.bin/ftp/ftp.c:1.168.2.5 --- src/usr.bin/ftp/ftp.c:1.168.2.4 Mon Jun 14 11:45:48 2021 +++ src/usr.bin/ftp/ftp.c Sun Oct 24 10:16:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.168.2.4 2021/06/14 11:45:48 martin Exp $ */ +/* $NetBSD: ftp.c,v 1.168.2.5 2021/10/24 10:16:05 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.4 2021/06/14 11:45:48 martin Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.168.2.5 2021/10/24 10:16:05 martin Exp $"); #endif #endif /* not lint */ @@ -1406,6 +1406,12 @@ initconn(void) data_addr.si_su.su_sin.sin_addr.s_addr = htonl(pack4(addr, 0)); data_addr.su_port = htons(pack2(port, 0)); + if (data_addr.si_su.su_sin.sin_addr.s_addr != + hisctladdr.si_su.su_sin.sin_addr.s_addr) { +fputs("Passive mode address mismatch.\n", +ttyout); +goto bad; + } } else if (strcmp(pasvcmd, "LPSV") == 0) { if (code / 10 == 22 && code != 228) { fputs("wrong server: return code must be 228\n", @@ -1440,6 +1446,12 @@ initconn(void) data_addr.si_su.su_sin.sin_addr.s_addr = htonl(pack4(addr, 0)); data_addr.su_port = htons(pack2(port, 0)); +if (data_addr.si_su.su_sin.sin_addr.s_addr != +hisctladdr.si_su.su_sin.sin_addr.s_addr) { + fputs("Passive mode address mismatch.\n", + ttyout); + goto bad; +} break; #ifdef INET6 case AF_INET6: @@ -1477,6 +1489,14 @@ initconn(void) } } data_addr.su_port = htons(pack2(port, 0)); +if (memcmp( +&data_addr.si_su.su_sin6.sin6_addr, +&hisctladdr.si_su.su_sin6.sin6_addr, +sizeof(data_addr.si_su.su_sin6.sin6_addr))) { + fputs("Passive mode address mismatch.\n", + ttyout); + goto bad; +} break; #endif default:
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Sun Oct 24 10:16:05 UTC 2021 Modified Files: src/usr.bin/ftp [netbsd-9]: ftp.c Log Message: Pull up following revision(s) (requested by lukem in ticket #1366): usr.bin/ftp/ftp.c: revision 1.173 ftp: validate address from PASV and LPSV response Fail if the server's response to PASV or LPSV contains an IP address that doesn't match that of the control connection. (EPSV already only uses the port portion of the server's response, per RFC 2428). Previously a hostile server could cause ftp to open a data connection elsewhere. Many other ftp implementations have had a similar change for many years, including those in popular browsers (before they deprecated FTP ...) Thanks to Simon Josefsson notifying me about https://lists.gnu.org/archive/html/bug-inetutils/2021-06/msg2.html To generate a diff of this commit: cvs rdiff -u -r1.168.2.4 -r1.168.2.5 src/usr.bin/ftp/ftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Sun Oct 24 10:13:40 UTC 2021 Modified Files: src/usr.bin/ftp [netbsd-9]: fetch.c Log Message: Pull up following revision(s) (requested by lukem in ticket #1365): usr.bin/ftp/fetch.c: revision 1.233 Use raw write(2) instead of fwrite(3) to avoid stream corruption because of the progress bar interrupts. From RVP. To generate a diff of this commit: cvs rdiff -u -r1.231.2.1 -r1.231.2.2 src/usr.bin/ftp/fetch.c 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/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.231.2.1 src/usr.bin/ftp/fetch.c:1.231.2.2 --- src/usr.bin/ftp/fetch.c:1.231.2.1 Mon Jun 14 11:34:20 2021 +++ src/usr.bin/ftp/fetch.c Sun Oct 24 10:13:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.231.2.1 2021/06/14 11:34:20 martin Exp $ */ +/* $NetBSD: fetch.c,v 1.231.2.2 2021/10/24 10:13:40 martin Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.231.2.1 2021/06/14 11:34:20 martin Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.231.2.2 2021/10/24 10:13:40 martin Exp $"); #endif /* not lint */ /* @@ -138,6 +138,43 @@ static int redirect_loop; ((urltype) == HTTP_URL_T) #endif +/** + * fwrite(3) replacement that just uses write(2). Many stdio implementations + * don't handle interrupts properly and corrupt the output. We are taking + * alarm interrupts because of the progress bar. + * + * Assumes `fp' is pristine with no prior I/O calls on it. + */ +static size_t +maxwrite(const void *buf, size_t size, size_t nmemb, FILE *fp) +{ + const char *p = buf; + ssize_t nwr = 0; + ssize_t n; + int fd = fileno(fp); + + size *= nmemb; /* assume no overflow */ + + while (size > 0) { + if ((n = write(fd, p, size)) == -1) { + switch (errno) { + case EINTR: + case EAGAIN: +#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN + case EWOULDBLOCK: +#endif +continue; + default: +return nwr; + } + } + p += n; + nwr += n; + size -= n; + } + return nwr; +} + /* * Determine if token is the next word in buf (case insensitive). * If so, advance buf past the token and any trailing LWS, and @@ -1650,7 +1687,7 @@ fetch_url(const char *url, const char *p } bytes += flen; bufrem -= flen; -if (fwrite(xferbuf, sizeof(char), flen, fout) +if (maxwrite(xferbuf, sizeof(char), flen, fout) != flen) { warn("Writing `%s'", savefile); goto cleanup_fetch_url;
CVS commit: [netbsd-9] src/usr.bin/ftp
Module Name:src Committed By: martin Date: Sun Oct 24 10:13:40 UTC 2021 Modified Files: src/usr.bin/ftp [netbsd-9]: fetch.c Log Message: Pull up following revision(s) (requested by lukem in ticket #1365): usr.bin/ftp/fetch.c: revision 1.233 Use raw write(2) instead of fwrite(3) to avoid stream corruption because of the progress bar interrupts. From RVP. To generate a diff of this commit: cvs rdiff -u -r1.231.2.1 -r1.231.2.2 src/usr.bin/ftp/fetch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.