Commit 1f8518c5 authored by Kamil Dudka's avatar Kamil Dudka
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
parent a52857cb
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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) {