files: when opening a file for copying, it should NOT be created

Weird bug.  The first occurrence is probably never hit because the
existing file has been tentatively opened fourteen lines earlier,
but that looks superfluous: double work.  And the second occurrence
will not be hit because the temp file is unlikely to have disappeared.
This commit is contained in:
Benno Schulenberg 2019-10-16 16:10:02 +02:00
parent 0f98466e2f
commit 022cc084a7

View File

@ -1738,7 +1738,7 @@ bool write_file(const char *name, FILE *stream, bool tmp,
goto cleanup_and_exit;
}
fd_source = open(realname, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR);
fd_source = open(realname, O_RDONLY);
if (fd_source != -1) {
f_source = fdopen(fd_source, "rb");
@ -1864,7 +1864,7 @@ bool write_file(const char *name, FILE *stream, bool tmp,
int fd_source;
FILE *f_source = NULL;
fd_source = open(tempname, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR);
fd_source = open(tempname, O_RDONLY);
if (fd_source != -1) {
f_source = fdopen(fd_source, "rb");