aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2008-08-22 22:57:25 +0000
committerDan Fandrich <dan@coneharvesters.com>2008-08-22 22:57:25 +0000
commite3ad6d2bd111d12ba0019a916270950cf83956bf (patch)
treefcd0c72f58ba214fc9f07c13b5a94117c9264d02 /src
parent4b64a8d20d8dfaa96efcfc100e250e13b0d29c34 (diff)
Fixed a problem when --dump-header - was given with more than one URL,
which caused an error when the second header was dumped due to stdout being closed. Added test case 1066 to verify. Also fixed a potential problem where a closed file descriptor might be used for an upload when more than one URL is given.
Diffstat (limited to 'src')
-rw-r--r--src/main.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 3127f0937..72a53163e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3890,9 +3890,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
int infilenum;
char *uploadfile=NULL; /* a single file, never a glob */
- int infd = STDIN_FILENO;
- bool infdopen;
- FILE *headerfilep = NULL;
curl_off_t uploadfilesize; /* -1 means unknown */
bool stillflags=TRUE;
@@ -4126,11 +4123,9 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
/* open file for output: */
if(strcmp(config->headerfile,"-")) {
heads.filename = config->headerfile;
- headerfilep=NULL;
}
else
- headerfilep=stdout;
- heads.stream = headerfilep;
+ heads.stream=stdout;
heads.config = config;
}
@@ -4218,6 +4213,8 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
for(i = 0;
(url = urls?glob_next_url(urls):(i?NULL:strdup(url)));
i++) {
+ int infd = STDIN_FILENO;
+ bool infdopen;
char *outfile;
struct timeval retrystart;
outfile = outfiles?strdup(outfiles):NULL;
@@ -4965,9 +4962,6 @@ show_error:
#endif
quit_urls:
- if(headerfilep)
- fclose(headerfilep);
-
if(url)
free(url);
@@ -5026,7 +5020,7 @@ quit_curl:
if (easycode)
curl_slist_append(easycode, "curl_easy_cleanup(hnd);");
- if(config->headerfile && !headerfilep && heads.stream)
+ if(heads.stream && (heads.stream != stdout))
fclose(heads.stream);
if(allocuseragent)