nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 022cc084a79e0501cb745267354c7de292c9d7bd
parent 0f98466e2fdee6834a5f906e41d21d9ad54015f1
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 16 Oct 2019 16:10:02 +0200

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.

Diffstat:
Msrc/files.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -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");