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
master
David Lawrence Ramsey 2005-06-05 19:18:11 +00:00
parent cc81436f81
commit 3db02389f4
1 changed files with 2 additions and 2 deletions

View File

@ -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;