From: Kamil Dudka Date: Mon, 30 Jul 2012 12:20:07 +0000 (+0200) Subject: file: use fdopen() for uploaded files if available X-Git-Tag: curl-7_28_0~149 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f8518c5d9aaa369dae85620973f9b5c1add3277;p=thirdparty%2Fcurl.git 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 --- diff --git a/lib/file.c b/lib/file.c index 4447c73f68..1025022f0e 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) {