aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2012-07-30 14:20:07 +0200
committerKamil Dudka <kdudka@redhat.com>2012-07-30 15:04:38 +0200
commit1f8518c5d9aaa369dae85620973f9b5c1add3277 (patch)
treefc05a61f906b39bcce723dcbb155c6b4617cf3bc
parenta52857cb025436df5a424dc603c54b97e4c2fab0 (diff)
file: use fdopen() for uploaded files if available
It eliminates noisy events when using inotify and fixes a TOCTOU issue. Bug: https://bugzilla.redhat.com/844385
-rw-r--r--lib/file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/file.c b/lib/file.c
index 4447c73f6..1025022f0 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -351,8 +351,12 @@ static CURLcode file_upload(struct connectdata *conn)
failf(data, "Can't open %s for writing", file->path);
return CURLE_WRITE_ERROR;
}
+#ifdef HAVE_FDOPEN
+ fp = fdopen(fd, "wb");
+#else
close(fd);
fp = fopen(file->path, "wb");
+#endif
}
if(!fp) {