Skip to content

Commit 1f8518c

Browse files
committed
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
1 parent a52857c commit 1f8518c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,12 @@ static CURLcode file_upload(struct connectdata *conn)
351351
failf(data, "Can't open %s for writing", file->path);
352352
return CURLE_WRITE_ERROR;
353353
}
354+
#ifdef HAVE_FDOPEN
355+
fp = fdopen(fd, "wb");
356+
#else
354357
close(fd);
355358
fp = fopen(file->path, "wb");
359+
#endif
356360
}
357361

358362
if(!fp) {

0 commit comments

Comments
 (0)