Commit 3db02389 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
parent cc81436f
Showing with 2 additions and 2 deletions
+2 -2
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment