summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-02 12:21:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-02 12:21:42 +0000
commitc3262bceee1a8018fad2e67ec616b4c4bed8b2a2 (patch)
tree5ada8262d0412c8557bc7b603a037171781631a5 /ext
parent0661411671f179ab4b35b195865052d2627acd1e (diff)
etc.c: retry with allocated string buffer
* ext/etc/etc.c (etc_systmpdir): retry with allocated string buffer if static buffer size is not enough. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/etc/etc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index ddd9441f9d8..0d2d9af7cbd 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -664,9 +664,15 @@ etc_systmpdir(void)
if (len > 0) {
tmpstr = path;
tmplen = len - 1;
+ if (len > sizeof(path)) tmpstr = 0;
}
# endif
tmpdir = rb_filesystem_str_new(tmpstr, tmplen);
+# if defined _CS_DARWIN_USER_TEMP_DIR
+ if (!tmpstr) {
+ confstr(_CS_DARWIN_USER_TEMP_DIR, RSTRING_PTR(tmpdir), len);
+ }
+# endif
#endif
FL_UNSET(tmpdir, FL_TAINT);
return tmpdir;