From 3db02389f4bf45863b9c096a9efc477680f94a48 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sun, 5 Jun 2005 19:18:11 +0000 Subject: [PATCH] in safe_tempfile(), open a newly created temporary file in "r+b" mode instead of "w+b" mode, since the latter truncates the file if it already exists, and we don't need to do that since it's an error if the file already exists git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2593 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/files.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/files.c b/src/files.c index 5e298111..31e9ed94 100644 --- a/src/files.c +++ b/src/files.c @@ -1134,7 +1134,7 @@ char *check_writable_directory(const char *path) /* This function calls mkstemp(($TMPDIR|P_tmpdir|/tmp/)"nano.XXXXXX"). * On success, it returns the malloc()ed filename and corresponding FILE - * stream, opened in "w+b" mode. On error, it returns NULL for the + * stream, opened in "r+b" mode. On error, it returns NULL for the * filename and leaves the FILE stream unchanged. */ char *safe_tempfile(FILE **f) { @@ -1165,7 +1165,7 @@ char *safe_tempfile(FILE **f) filedesc = mkstemp(full_tempdir); if (filedesc != -1) - *f = fdopen(filedesc, "w+b"); + *f = fdopen(filedesc, "r+b"); else { free(full_tempdir); full_tempdir = NULL; -- 2.39.5