Module Name: src Committed By: christos Date: Sat Nov 25 15:39:18 UTC 2017
Modified Files: src/usr.bin/ftp: fetch.c main.c Log Message: Make outfile always allocated, free it to set it to NULL, and don't move it around. To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.123 -r1.124 src/usr.bin/ftp/main.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.228 src/usr.bin/ftp/fetch.c:1.229 --- src/usr.bin/ftp/fetch.c:1.228 Wed Feb 15 06:52:11 2017 +++ src/usr.bin/ftp/fetch.c Sat Nov 25 10:39:17 2017 @@ -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 @@ fetch_ftp(const char *url) 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 @@ auto_fetch(int argc, char *argv[]) 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; } Index: src/usr.bin/ftp/main.c diff -u src/usr.bin/ftp/main.c:1.123 src/usr.bin/ftp/main.c:1.124 --- src/usr.bin/ftp/main.c:1.123 Thu Apr 23 19:31:23 2015 +++ src/usr.bin/ftp/main.c Sat Nov 25 10:39:17 2017 @@ -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 @@ __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.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 @@ main(int volatile argc, char **volatile break; case 'o': - outfile = optarg; + outfile = ftp_strdup(optarg); if (strcmp(outfile, "-") == 0) ttyout = stderr; break;