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-d3aeb78583b8master
parent
cc81436f81
commit
3db02389f4
|
@ -1134,7 +1134,7 @@ char *check_writable_directory(const char *path)
|
||||||
|
|
||||||
/* This function calls mkstemp(($TMPDIR|P_tmpdir|/tmp/)"nano.XXXXXX").
|
/* This function calls mkstemp(($TMPDIR|P_tmpdir|/tmp/)"nano.XXXXXX").
|
||||||
* On success, it returns the malloc()ed filename and corresponding FILE
|
* 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. */
|
* filename and leaves the FILE stream unchanged. */
|
||||||
char *safe_tempfile(FILE **f)
|
char *safe_tempfile(FILE **f)
|
||||||
{
|
{
|
||||||
|
@ -1165,7 +1165,7 @@ char *safe_tempfile(FILE **f)
|
||||||
filedesc = mkstemp(full_tempdir);
|
filedesc = mkstemp(full_tempdir);
|
||||||
|
|
||||||
if (filedesc != -1)
|
if (filedesc != -1)
|
||||||
*f = fdopen(filedesc, "w+b");
|
*f = fdopen(filedesc, "r+b");
|
||||||
else {
|
else {
|
||||||
free(full_tempdir);
|
free(full_tempdir);
|
||||||
full_tempdir = NULL;
|
full_tempdir = NULL;
|
||||||
|
|
Loading…
Reference in New Issue