Source-Changes-HG archive

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

[src/netbsd-8]: src/usr.bin/ftp Backout ticket #1763 for now - trust anchors ...



details:   https://anonhg.NetBSD.org/src/rev/ae2fce2dfd72
branches:  netbsd-8
changeset: 370023:ae2fce2dfd72
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Sep 12 15:05:21 2022 +0000

description:
Backout ticket #1763 for now - trust anchors are not solved.

diffstat:

 usr.bin/ftp/Makefile      |    6 +-
 usr.bin/ftp/cmds.c        |   32 +--
 usr.bin/ftp/complete.c    |    7 +-
 usr.bin/ftp/domacro.c     |    6 +-
 usr.bin/ftp/extern.h      |   10 +-
 usr.bin/ftp/fetch.c       |  258 ++++++++++----------------------
 usr.bin/ftp/ftp.1         |  362 ++++++++++++++++++---------------------------
 usr.bin/ftp/ftp.c         |  127 +++++----------
 usr.bin/ftp/ftp_var.h     |    5 +-
 usr.bin/ftp/main.c        |  122 +++-----------
 usr.bin/ftp/progressbar.c |   74 +++++++-
 usr.bin/ftp/progressbar.h |    5 +-
 usr.bin/ftp/ssl.c         |  217 ++++++++++-----------------
 usr.bin/ftp/ssl.h         |   25 ++-
 usr.bin/ftp/util.c        |   26 +--
 usr.bin/ftp/version.h     |    6 +-
 16 files changed, 502 insertions(+), 786 deletions(-)

diffs (truncated from 3227 to 300 lines):

diff -r f59dd936af3c -r ae2fce2dfd72 usr.bin/ftp/Makefile
--- a/usr.bin/ftp/Makefile      Mon Sep 12 14:49:03 2022 +0000
+++ b/usr.bin/ftp/Makefile      Mon Sep 12 15:05:21 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.37.2.1 2022/09/12 14:46:51 martin Exp $
+#      $NetBSD: Makefile,v 1.37.2.2 2022/09/12 15:05:21 martin Exp $
 #      from: @(#)Makefile      8.2 (Berkeley) 4/3/94
 
 .include <bsd.own.mk>
@@ -8,7 +8,6 @@
 PROG=  ftp
 SRCS=  cmds.c cmdtab.c complete.c domacro.c fetch.c ftp.c main.c \
        progressbar.c ruserpass.c util.c
-SRCS+= ssl.c
 
 # Uncomment the following to provide defaults for gate-ftp operation
 #
@@ -20,6 +19,7 @@
 LDADD+=        -ledit -lterminfo
 DPADD+=        ${LIBEDIT} ${LIBTERMINFO}
 CPPFLAGS+= -DWITH_SSL
+SRCS+=ssl.c
 LDADD+= -lssl -lcrypto
 DPADD+= ${LIBSSL} ${LIBCRYPTO}
 .endif
@@ -31,6 +31,4 @@
 cmds.o fetch.o: version.h
 main.o:        ftp_var.h
 
-CWARNFLAGS.gcc+=       ${GCC_NO_FORMAT_OVERFLOW}
-
 .include <bsd.prog.mk>
diff -r f59dd936af3c -r ae2fce2dfd72 usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c        Mon Sep 12 14:49:03 2022 +0000
+++ b/usr.bin/ftp/cmds.c        Mon Sep 12 15:05:21 2022 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: cmds.c,v 1.137.8.1 2022/09/12 14:46:51 martin Exp $    */
+/*     $NetBSD: cmds.c,v 1.137.8.2 2022/09/12 15:05:21 martin Exp $    */
 
 /*-
- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996-2009 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -96,7 +96,7 @@
 #if 0
 static char sccsid[] = "@(#)cmds.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: cmds.c,v 1.137.8.1 2022/09/12 14:46:51 martin Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.137.8.2 2022/09/12 15:05:21 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -1131,7 +1131,7 @@
                options |= SO_DEBUG;
        else
                options &= ~SO_DEBUG;
-       fprintf(ttyout, "Debugging %s (debug=%d).\n", onoff(ftp_debug), ftp_debug);
+       fprintf(ttyout, "Debugging %s (ftp_debug=%d).\n", onoff(ftp_debug), ftp_debug);
        code = ftp_debug > 0;
 }
 
@@ -1158,8 +1158,7 @@
        }
        if (r == COMPLETE) {
                dirchange = 1;
-               remotecwd[0] = '\0';
-               remcwdvalid = 0;
+               updateremotecwd();
        }
 }
 
@@ -1545,9 +1544,9 @@
                UPRINTF("usage: %s\n", argv[0]);
                return;
        }
-       if (!remcwdvalid || remotecwd[0] == '\0')
+       if (! remotecwd[0])
                updateremotecwd();
-       if (remotecwd[0] == '\0')
+       if (! remotecwd[0])
                fprintf(ttyout, "Unable to determine remote directory\n");
        else {
                fprintf(ttyout, "Remote directory: %s\n", remotecwd);
@@ -1776,18 +1775,6 @@
        exit(0);
 }
 
-void __dead
-justquit(void)
-{
-
-       quit(0, NULL);
-       /*
-        * quit is not __dead, but for our invocation it never will return,
-        * but some compilers are not smart enough to find this out.
-        */
-       exit(0);
-}
-
 /*
  * Terminate session, but don't exit.
  * May be called with 0, NULL.
@@ -2197,7 +2184,7 @@
                                        }
                                        break;
                                }
-                               /* FALLTHROUGH */
+                               /* intentional drop through */
                        default:
                                *cp2++ = *cp1;
                                break;
@@ -2372,8 +2359,7 @@
        }
        if (r == COMPLETE) {
                dirchange = 1;
-               remotecwd[0] = '\0';
-               remcwdvalid = 0;
+               updateremotecwd();
        }
 }
 
diff -r f59dd936af3c -r ae2fce2dfd72 usr.bin/ftp/complete.c
--- a/usr.bin/ftp/complete.c    Mon Sep 12 14:49:03 2022 +0000
+++ b/usr.bin/ftp/complete.c    Mon Sep 12 15:05:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: complete.c,v 1.46.38.1 2022/09/12 14:46:51 martin Exp $        */
+/*     $NetBSD: complete.c,v 1.46.38.2 2022/09/12 15:05:21 martin Exp $        */
 
 /*-
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: complete.c,v 1.46.38.1 2022/09/12 14:46:51 martin Exp $");
+__RCSID("$NetBSD: complete.c,v 1.46.38.2 2022/09/12 15:05:21 martin Exp $");
 #endif /* not lint */
 
 /*
@@ -99,10 +99,11 @@
        }
 
        if (!list) {
+               matchlen = 0;
                lastmatch = words->sl_str[0];
                matchlen = strlen(lastmatch);
                for (i = 1 ; i < words->sl_cur ; i++) {
-                       for (j = wordlen; j < strlen(words->sl_str[i]); j++)
+                       for (j = wordlen ; j < strlen(words->sl_str[i]); j++)
                                if (lastmatch[j] != words->sl_str[i][j])
                                        break;
                        if (j < matchlen)
diff -r f59dd936af3c -r ae2fce2dfd72 usr.bin/ftp/domacro.c
--- a/usr.bin/ftp/domacro.c     Mon Sep 12 14:49:03 2022 +0000
+++ b/usr.bin/ftp/domacro.c     Mon Sep 12 15:05:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: domacro.c,v 1.22.38.1 2022/09/12 14:46:51 martin Exp $ */
+/*     $NetBSD: domacro.c,v 1.22.38.2 2022/09/12 15:05:21 martin Exp $ */
 
 /*
  * Copyright (c) 1985, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)domacro.c  8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: domacro.c,v 1.22.38.1 2022/09/12 14:46:51 martin Exp $");
+__RCSID("$NetBSD: domacro.c,v 1.22.38.2 2022/09/12 15:05:21 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -102,7 +102,7 @@
                                        }
                                        break;
                                }
-                               /* FALLTHROUGH */
+                               /* intentional drop through */
                        default:
                                *cp2++ = *cp1;
                                break;
diff -r f59dd936af3c -r ae2fce2dfd72 usr.bin/ftp/extern.h
--- a/usr.bin/ftp/extern.h      Mon Sep 12 14:49:03 2022 +0000
+++ b/usr.bin/ftp/extern.h      Mon Sep 12 15:05:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.80.24.1 2022/09/12 14:46:51 martin Exp $  */
+/*     $NetBSD: extern.h,v 1.80.24.2 2022/09/12 15:05:21 martin Exp $  */
 
 /*-
  * Copyright (c) 1996-2009 The NetBSD Foundation, Inc.
@@ -173,7 +173,6 @@
 void   put(int, char **);
 void   pwd(int, char **);
 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 *,
@@ -243,14 +242,7 @@
 int    ftp_connect(int, const struct sockaddr *, socklen_t, int);
 int    ftp_listen(int, int);
 int    ftp_poll(struct pollfd *, int, int);
-#ifndef SMALL
 void   *ftp_malloc(size_t);
 StringList *ftp_sl_init(void);
 void   ftp_sl_add(StringList *, char *);
 char   *ftp_strdup(const char *);
-#else
-#define        ftp_malloc(a)   malloc(a);
-#define ftp_sl_init()  sl_init()
-#define ftp_sl_add(a, b)       sl_add((a), (b))
-#define ftp_strdup(a)  strdup(a)
-#endif
diff -r f59dd936af3c -r ae2fce2dfd72 usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c       Mon Sep 12 14:49:03 2022 +0000
+++ b/usr.bin/ftp/fetch.c       Mon Sep 12 15:05:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fetch.c,v 1.228.4.1 2022/09/12 14:46:51 martin Exp $   */
+/*     $NetBSD: fetch.c,v 1.228.4.2 2022/09/12 15:05:21 martin Exp $   */
 
 /*-
  * Copyright (c) 1997-2015 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.228.4.1 2022/09/12 14:46:51 martin Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.228.4.2 2022/09/12 15:05:21 martin Exp $");
 #endif /* not lint */
 
 /*
@@ -106,13 +106,12 @@
 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 *);
@@ -139,43 +138,6 @@
        ((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
@@ -275,7 +237,7 @@
        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)) {



Home | Main Index | Thread Index | Old Index