Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/ftp Make outfile always allocated, free it to set it...



details:   https://anonhg.NetBSD.org/src/rev/2c03bda323c3
branches:  trunk
changeset: 828053:2c03bda323c3
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 25 15:39:17 2017 +0000

description:
Make outfile always allocated, free it to set it to NULL, and don't move it
around.

diffstat:

 usr.bin/ftp/fetch.c |  18 ++++++++++--------
 usr.bin/ftp/main.c  |   6 +++---
 2 files changed, 13 insertions(+), 11 deletions(-)

diffs (77 lines):

diff -r d125a253c052 -r 2c03bda323c3 usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c       Sat Nov 25 14:46:53 2017 +0000
+++ b/usr.bin/ftp/fetch.c       Sat Nov 25 15:39:17 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fetch.c,v 1.228 2017/02/15 11:52:11 nonaka Exp $       */
+/*     $NetBSD: fetch.c,v 1.229 2017/11/25 15:39:17 christos 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 2017/02/15 11:52:11 nonaka Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.229 2017/11/25 15:39:17 christos Exp $");
 #endif /* not lint */
 
 /*
@@ -2097,14 +2097,15 @@
                mget(xargc, xargv);
                interactive = ointeractive;
        } else {
-               if (outfile == NULL) {
+               char *destfile = outfile;
+               if (destfile == NULL) {
                        cp = strrchr(file, '/');        /* find savefile */
                        if (cp != NULL)
-                               outfile = cp + 1;
+                               destfile = cp + 1;
                        else
-                               outfile = file;
+                               destfile = file;
                }
-               xargv[2] = (char *)outfile;
+               xargv[2] = (char *)destfile;
                xargv[3] = NULL;
                xargc++;
                if (restartautofetch)
@@ -2250,8 +2251,9 @@
                        anonftp = 2;    /* Handle "automatic" transfers. */
                rval = go_fetch(argv[argpos]);
                if (outfile != NULL && strcmp(outfile, "-") != 0
-                   && outfile[0] != '|')
-                       outfile = NULL;
+                   && outfile[0] != '|') {
+                       FREEPTR(outfile);
+               }
                if (rval > 0)
                        rval = argpos + 1;
        }
diff -r d125a253c052 -r 2c03bda323c3 usr.bin/ftp/main.c
--- a/usr.bin/ftp/main.c        Sat Nov 25 14:46:53 2017 +0000
+++ b/usr.bin/ftp/main.c        Sat Nov 25 15:39:17 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.123 2015/04/23 23:31:23 lukem Exp $ */
+/*     $NetBSD: main.c,v 1.124 2017/11/25 15:39:17 christos Exp $      */
 
 /*-
  * Copyright (c) 1996-2015 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.123 2015/04/23 23:31:23 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.124 2017/11/25 15:39:17 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -324,7 +324,7 @@
                        break;
 
                case 'o':
-                       outfile = optarg;
+                       outfile = ftp_strdup(optarg);
                        if (strcmp(outfile, "-") == 0)
                                ttyout = stderr;
                        break;



Home | Main Index | Thread Index | Old Index