summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-23 15:41:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-23 15:41:17 +0000
commit3b6dac4e1dc5e24d641353637a2962b58f3a7b6c (patch)
tree16754d090b3d6bd9d7be4142b4f164b1a3d69500 /file.c
parent359ba4eb05089b89c0b5ef14ab8e928f370a536f (diff)
* eval.c (rb_load, search_required, rb_require_safe, rb_require): use
frozen shared string to avoid outside modification. [ruby-dev:24580] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/file.c b/file.c
index d656b70..c9aa494 100644
--- a/file.c
+++ b/file.c
@@ -3936,6 +3936,7 @@ rb_find_file_ext(filep, ext)
if (rb_safe_level() >= 2 && OBJ_TAINTED(fname)) {
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
+ OBJ_FREEZE(fname);
f = StringValueCStr(fname);
*filep = fname;
}
@@ -3944,6 +3945,7 @@ rb_find_file_ext(filep, ext)
for (i=0; ext[i]; i++) {
fname = rb_str_dup(*filep);
rb_str_cat2(fname, ext[i]);
+ OBJ_FREEZE(fname);
if (file_load_ok(StringValueCStr(fname))) {
*filep = fname;
return i+1;
@@ -3964,6 +3966,7 @@ rb_find_file_ext(filep, ext)
for (j=0; ext[j]; j++) {
fname = rb_str_dup(*filep);
rb_str_cat2(fname, ext[j]);
+ OBJ_FREEZE(fname);
found = dln_find_file(StringValueCStr(fname), path);
if (found && file_load_ok(found)) {
*filep = fname;
@@ -3987,6 +3990,7 @@ rb_find_file(path)
if (rb_safe_level() >= 1 && OBJ_TAINTED(path)) {
rb_raise(rb_eSecurityError, "loading from unsafe path %s", f);
}
+ OBJ_FREEZE(path);
f = StringValueCStr(path);
}
@@ -4045,7 +4049,9 @@ rb_find_file(path)
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
if (file_load_ok(f)) {
- return rb_str_new2(f);
+ tmp = rb_str_new2(f);
+ OBJ_FREEZE(tmp);
+ return tmp;
}
return 0;
}