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
This commit is contained in:
Kamil Dudka 2012-07-30 14:20:07 +02:00
parent a52857cb02
commit 1f8518c5d9
1 changed files with 4 additions and 0 deletions

View File

@ -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) {