Browse files

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
  • Loading branch information...
1 parent a52857c commit 1f8518c5d9aaa369dae85620973f9b5c1add3277 @kdudka kdudka committed Jul 30, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/file.c
View
4 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) {

0 comments on commit 1f8518c

Please sign in to comment.