summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-03-01 14:48:37 +0100
committerAndy Wingo <wingo@pobox.com>2017-03-01 14:48:37 +0100
commita86bb2e613f050e63275c357d7df41f019d5efc8 (patch)
tree63c1cb09dac54494f8e88ce0be51e2543366131f /libguile
parente13cd5c77c030f22e3f5c27f15bb979bfda7d2ba (diff)
Fix (mkstemp! "XX" 0) errors
* libguile/filesys.c (scm_i_mkstemp): Validate "mode" argument as a string, and validate writability of template string early too. Thanks to Jean Louis for the bug report.
Diffstat (limited to 'libguile')
-rw-r--r--libguile/filesys.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c
index 40d5a41d3..b5b7e723b 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1475,6 +1475,14 @@ SCM_DEFINE (scm_i_mkstemp, "mkstemp!", 1, 1, 0,
int open_flags, is_binary;
SCM port;
+ SCM_VALIDATE_STRING (SCM_ARG1, tmpl);
+ if (!SCM_UNBNDP (mode))
+ SCM_VALIDATE_STRING (SCM_ARG2, mode);
+
+ /* Ensure tmpl is mutable. */
+ scm_i_string_start_writing (tmpl);
+ scm_i_string_stop_writing ();
+
scm_dynwind_begin (0);
c_tmpl = scm_to_locale_string (tmpl);