Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/ftp * fix initialisation of home[]



details:   https://anonhg.NetBSD.org/src/rev/d344136f555b
branches:  trunk
changeset: 476867:d344136f555b
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Sep 30 12:18:03 1999 +0000

description:
* fix initialisation of home[]
* fetch_url(): if path would be NULL, return strdup("")

diffstat:

 usr.bin/ftp/cmds.c   |  11 ++++++-----
 usr.bin/ftp/extern.h |   4 ++--
 usr.bin/ftp/fetch.c  |   6 ++++--
 usr.bin/ftp/main.c   |  12 ++++++------
 4 files changed, 18 insertions(+), 15 deletions(-)

diffs (132 lines):

diff -r ce91aca22086 -r d344136f555b usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c        Thu Sep 30 12:12:41 1999 +0000
+++ b/usr.bin/ftp/cmds.c        Thu Sep 30 12:18:03 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.63 1999/09/28 06:47:38 lukem Exp $  */
+/*     $NetBSD: cmds.c,v 1.64 1999/09/30 12:18:03 lukem Exp $  */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -107,7 +107,7 @@
 #if 0
 static char sccsid[] = "@(#)cmds.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: cmds.c,v 1.63 1999/09/28 06:47:38 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.64 1999/09/30 12:18:03 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -136,7 +136,6 @@
 
 jmp_buf        jabort;
 char   *mname;
-char   *home = "/";
 
 struct types {
        char    *t_name;
@@ -1042,8 +1041,10 @@
        char buf[MAXPATHLEN];
        char *locdir;
 
-       if (argc < 2)
-               argc++, argv[1] = home;
+       if (argc < 2) {
+               argc++;
+               argv[1] = home;
+       }
        if (argc != 2) {
                fprintf(ttyout, "usage: %s local-directory\n", argv[0]);
                code = -1;
diff -r ce91aca22086 -r d344136f555b usr.bin/ftp/extern.h
--- a/usr.bin/ftp/extern.h      Thu Sep 30 12:12:41 1999 +0000
+++ b/usr.bin/ftp/extern.h      Thu Sep 30 12:18:03 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.38 1999/09/28 06:47:40 lukem Exp $        */
+/*     $NetBSD: extern.h,v 1.39 1999/09/30 12:18:03 lukem Exp $        */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -211,7 +211,7 @@
 extern struct  cmd cmdtab[];
 extern FILE    *cout;
 extern int     data;
-extern char    *home;
+extern char    home[];
 extern int     proxy;
 extern char    reply_string[];
 extern int     NCMDS;
diff -r ce91aca22086 -r d344136f555b usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c       Thu Sep 30 12:12:41 1999 +0000
+++ b/usr.bin/ftp/fetch.c       Thu Sep 30 12:18:03 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fetch.c,v 1.80 1999/09/29 00:44:01 lukem Exp $ */
+/*     $NetBSD: fetch.c,v 1.81 1999/09/30 12:18:03 lukem Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.80 1999/09/29 00:44:01 lukem Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.81 1999/09/30 12:18:03 lukem Exp $");
 #endif /* not lint */
 
 /*
@@ -401,6 +401,8 @@
        }
        if (tport != NULL);
                *port = xstrdup(tport);
+       if (*path == NULL)
+               *path = xstrdup("");
 
        if (debug)
                fprintf(ttyout,
diff -r ce91aca22086 -r d344136f555b usr.bin/ftp/main.c
--- a/usr.bin/ftp/main.c        Thu Sep 30 12:12:41 1999 +0000
+++ b/usr.bin/ftp/main.c        Thu Sep 30 12:18:03 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.53 1999/09/28 06:47:42 lukem Exp $  */
+/*     $NetBSD: main.c,v 1.54 1999/09/30 12:18:04 lukem Exp $  */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -72,7 +72,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.53 1999/09/28 06:47:42 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.54 1999/09/30 12:18:04 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -98,6 +98,8 @@
 #define NO_PROXY       "no_proxy"      /* env var with list of non-proxied
                                         * hosts, comma or space separated */
 
+char home[MAXPATHLEN] = "/";
+
 int main __P((int, char **));
 
 int
@@ -107,7 +109,7 @@
 {
        int ch, top, rval;
        struct passwd *pw = NULL;
-       char *cp, *ep, homedir[MAXPATHLEN];
+       char *cp, *ep;
        int dumbterm, s, len;
 
        ftpport = "ftp";
@@ -354,10 +356,8 @@
        }
        if (pw == NULL)
                pw = getpwuid(getuid());
-       if (pw != NULL) {
-               home = homedir;
+       if (pw != NULL)
                (void)strlcpy(home, pw->pw_dir, sizeof(home));
-       }
 
        setttywidth(0);
        (void)xsignal(SIGWINCH, setttywidth);



Home | Main Index | Thread Index | Old Index