mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
34e8a8623f
commit
c606447c00
2 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue May 16 15:34:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* re.c (rb_reg_initialize): should not allow modifying literal
|
||||||
|
regexps. frozen check moved from rb_reg_initialize_m as well.
|
||||||
|
|
||||||
Tue May 16 09:20:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue May 16 09:20:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* re.c (rb_reg_initialize): should not modify untainted objects in
|
* re.c (rb_reg_initialize): should not modify untainted objects in
|
||||||
|
|
6
re.c
6
re.c
|
@ -152,6 +152,7 @@ rb_memsearch(x0, m, y0, n)
|
||||||
return s-y;
|
return s-y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define REG_LITERAL FL_USER5
|
||||||
#define REG_CASESTATE FL_USER0
|
#define REG_CASESTATE FL_USER0
|
||||||
#define KCODE_NONE 0
|
#define KCODE_NONE 0
|
||||||
#define KCODE_EUC FL_USER1
|
#define KCODE_EUC FL_USER1
|
||||||
|
@ -1335,6 +1336,9 @@ rb_reg_initialize(obj, s, len, options)
|
||||||
|
|
||||||
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
|
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
|
||||||
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
|
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
|
||||||
|
rb_check_frozen(obj);
|
||||||
|
if (FL_TEST(obj, REG_LITERAL))
|
||||||
|
rb_raise(rb_eSecurityError, "can't modify literal regexp");
|
||||||
if (re->ptr) re_free_pattern(re->ptr);
|
if (re->ptr) re_free_pattern(re->ptr);
|
||||||
if (re->str) free(re->str);
|
if (re->str) free(re->str);
|
||||||
re->ptr = 0;
|
re->ptr = 0;
|
||||||
|
@ -1374,6 +1378,7 @@ rb_reg_initialize(obj, s, len, options)
|
||||||
if (options & ~0xf) {
|
if (options & ~0xf) {
|
||||||
kcode_reset_option();
|
kcode_reset_option();
|
||||||
}
|
}
|
||||||
|
if (ruby_in_compile) FL_SET(obj, REG_LITERAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE rb_reg_s_alloc _((VALUE));
|
static VALUE rb_reg_s_alloc _((VALUE));
|
||||||
|
@ -1656,7 +1661,6 @@ rb_reg_initialize_m(argc, argv, self)
|
||||||
long len;
|
long len;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
rb_check_frozen(self);
|
|
||||||
if (argc == 0 || argc > 3) {
|
if (argc == 0 || argc > 3) {
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue