diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-05-08 17:39:51 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-05-08 17:39:51 +0200 |
commit | e350ca4e73771c5a23e08ecc25ea4d3a966e51f8 (patch) | |
tree | 8c92ae380af20c6b63470fdeea546c12f01b0773 /uclient-fetch.c | |
parent | 58dec1d4bf3b66d62454775bd8fd4f3d347b3806 (diff) | |
download | uclient-e350ca4e73771c5a23e08ecc25ea4d3a966e51f8.tar.gz |
fetch: always use O_EXCL when creating output files, use unlink if -O is specified
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uclient-fetch.c')
-rw-r--r-- | uclient-fetch.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/uclient-fetch.c b/uclient-fetch.c index 632cdbb..1644921 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -49,7 +49,7 @@ static int open_output_file(const char *path, bool create) int ret; if (create) - flags |= O_CREAT; + flags |= O_CREAT | O_EXCL; if (output_file) { if (!strcmp(output_file, "-")) @@ -58,13 +58,10 @@ static int open_output_file(const char *path, bool create) if (!quiet) fprintf(stderr, "Writing to stdout\n"); + unlink(output_file); return open(output_file, flags, 0644); } - /* Don't automatically overwrite files if the name is derived from the URL */ - if (create) - flags |= O_EXCL; - filename = uclient_get_url_filename(path, "index.html"); if (!quiet) fprintf(stderr, "Writing to '%s'\n", filename); |