SHA256
1
0
forked from pool/readline
readline/readline-6.3-rltrace.patch

43 lines
987 B
Diff

Even if used only by developers to debug readline library do not open
temporary files from public location without O_EXCL (bcn#868822).
---
lib/readline/util.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
--- lib/readline/util.c
+++ lib/readline/util.c 2018-09-20 06:47:51.238715688 +0000
@@ -489,10 +489,12 @@ _rl_trace (va_alist)
if (_rl_tracefp == 0)
_rl_tropen ();
+ if (!_rl_tracefp)
+ goto out;
vfprintf (_rl_tracefp, format, args);
fprintf (_rl_tracefp, "\n");
fflush (_rl_tracefp);
-
+out:
va_end (args);
}
@@ -512,7 +514,7 @@ _rl_tropen (void)
#endif
snprintf (fnbuf, sizeof (fnbuf), "%s/rltrace.%ld", x, (long)getpid());
unlink(fnbuf);
- _rl_tracefp = fopen (fnbuf, "w+");
+ _rl_tracefp = fopen (fnbuf, "w+xe");
return _rl_tracefp != 0;
}
@@ -521,7 +523,8 @@ _rl_trclose (void)
{
int r;
- r = fclose (_rl_tracefp);
+ if (_rl_tracefp)
+ r = fclose (_rl_tracefp);
_rl_tracefp = 0;
return r;
}