summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-19 04:36:34 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-19 04:36:34 +0000
commit9be426a0ec6ec98b61a7d99f2d77d5fdf79a3837 (patch)
tree0c70d582217d4ecf4ec7c05f5ad56d78eed47257 /io.c
parente7392b3f844b7fe2517d8c671102dcc886a96edb (diff)
* eval.c (rb_f_require): searches ".rb" and ".so" at the same
time. previous behavior (search ".rb", then ".so") has a security risk (ruby-bugs#PR140). * regex.c (re_compile_pattern): avoid pushing unnecessary option_set. * eval.c (rb_load): tainted string is OK if wrapped *and* $SAFE >= 4. * eval.c (rb_thread_start_0): should not nail down higher blocks before preserving original context (i.e. should not alter original context). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/io.c b/io.c
index 35c043b676..a950c9e634 100644
--- a/io.c
+++ b/io.c
@@ -3346,12 +3346,17 @@ static void
opt_i_set(val)
VALUE val;
{
- if (ruby_inplace_mode) free(ruby_inplace_mode);
+ long len;
+
if (!RTEST(val)) {
+ if (ruby_inplace_mode) free(ruby_inplace_mode);
ruby_inplace_mode = 0;
return;
}
- ruby_inplace_mode = strdup(STR2CSTR(val));
+ STR2CSTR(val);
+ len = RSTRING(val)->len;
+ REALLOC_N(ruby_inplace_mode, char, len + 1);
+ ((char *)MEMCPY(ruby_inplace_mode, RSTRING(val)->ptr, char, len))[len] = '\0';
}
void