69 lines
1.9 KiB
Diff
69 lines
1.9 KiB
Diff
Index: contrib/tnftp/src/fetch.c
|
|
===================================================================
|
|
--- contrib/tnftp/src/fetch.c.orig
|
|
+++ contrib/tnftp/src/fetch.c
|
|
@@ -547,7 +547,7 @@
|
|
url_decode(decodedpath);
|
|
|
|
if (outfile)
|
|
- savefile = ftp_strdup(outfile);
|
|
+ savefile = outfile;
|
|
else {
|
|
cp = strrchr(decodedpath, '/'); /* find savefile */
|
|
if (cp != NULL)
|
|
@@ -571,8 +571,7 @@
|
|
rangestart = rangeend = entitylen = -1;
|
|
mtime = -1;
|
|
if (restartautofetch) {
|
|
- if (strcmp(savefile, "-") != 0 && *savefile != '|' &&
|
|
- stat(savefile, &sb) == 0)
|
|
+ if (stat(savefile, &sb) == 0)
|
|
restart_point = sb.st_size;
|
|
}
|
|
if (urltype == FILE_URL_T) { /* file:// URLs */
|
|
@@ -1098,17 +1097,25 @@
|
|
} /* end of ftp:// or http:// specific setup */
|
|
|
|
/* Open the output file. */
|
|
- if (strcmp(savefile, "-") == 0) {
|
|
- fout = stdout;
|
|
- } else if (*savefile == '|') {
|
|
- oldintp = xsignal(SIGPIPE, SIG_IGN);
|
|
- fout = popen(savefile + 1, "w");
|
|
- if (fout == NULL) {
|
|
- warn("Can't execute `%s'", savefile + 1);
|
|
- goto cleanup_fetch_url;
|
|
+
|
|
+ /*
|
|
+ * Only trust filenames with special meaning if they came from
|
|
+ * the command line
|
|
+ */
|
|
+ if (outfile == savefile) {
|
|
+ if (strcmp(savefile, "-") == 0) {
|
|
+ fout = stdout;
|
|
+ } else if (*savefile == '|') {
|
|
+ oldintp = xsignal(SIGPIPE, SIG_IGN);
|
|
+ fout = popen(savefile + 1, "w");
|
|
+ if (fout == NULL) {
|
|
+ warn("Can't execute `%s'", savefile + 1);
|
|
+ goto cleanup_fetch_url;
|
|
+ }
|
|
+ closefunc = pclose;
|
|
}
|
|
- closefunc = pclose;
|
|
- } else {
|
|
+ }
|
|
+ if (fout == NULL) {
|
|
if ((rangeend != -1 && rangeend <= restart_point) ||
|
|
(rangestart == -1 && filesize != -1 && filesize <= restart_point)) {
|
|
/* already done */
|
|
@@ -1318,7 +1325,8 @@
|
|
(*closefunc)(fout);
|
|
if (res0)
|
|
freeaddrinfo(res0);
|
|
- FREEPTR(savefile);
|
|
+ if (savefile != outfile)
|
|
+ FREEPTR(savefile);
|
|
FREEPTR(uuser);
|
|
if (pass != NULL)
|
|
memset(pass, 0, strlen(pass));
|