summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-05 14:51:42 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-05 14:51:42 +0000
commit24b531f9a16234f5f064ef9fb1536476c05017e8 (patch)
treed12e06426be00b4915c9084359a8a027c3c03012 /parse.y
parent073f93d7cbd462f5227467b1a1d498281d3f3353 (diff)
merge revision(s) r42988: [Backport #8928]
* parse.y (intern_str): sigil only names are junk, at least one identifier character is needed. [ruby-dev:47723] [Bug #8928] * parse.y (rb_enc_symname_type): fix out of bound access. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y9
1 files changed, 8 insertions, 1 deletions
diff --git a/parse.y b/parse.y
index 9f8b284924..e39a9d01ff 100644
--- a/parse.y
+++ b/parse.y
@@ -10136,6 +10136,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc)
if (m >= e || (*m != '_' && !rb_enc_isalpha(*m, enc) && ISASCII(*m)))
return -1;
while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
+ if (m >= e) break;
switch (*m) {
case '!': case '?':
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
@@ -10243,7 +10244,8 @@ intern_str(VALUE str)
enc = rb_enc_get(str);
symenc = enc;
- if (rb_cString && !rb_enc_asciicompat(enc)) {
+ if (!len || (rb_cString && !rb_enc_asciicompat(enc))) {
+ junk:
id = ID_JUNK;
goto new_id;
}
@@ -10251,6 +10253,7 @@ intern_str(VALUE str)
id = 0;
switch (*m) {
case '$':
+ if (len < 2) goto junk;
id |= ID_GLOBAL;
if ((mb = is_special_global_name(++m, e, enc)) != 0) {
if (!--mb) symenc = rb_usascii_encoding();
@@ -10259,10 +10262,12 @@ intern_str(VALUE str)
break;
case '@':
if (m[1] == '@') {
+ if (len < 3) goto junk;
m++;
id |= ID_CLASS;
}
else {
+ if (len < 2) goto junk;
id |= ID_INSTANCE;
}
m++;
@@ -10288,6 +10293,8 @@ intern_str(VALUE str)
if (m[last] == '=') {
/* attribute assignment */
+ if (!rb_enc_symname2_p(name, last, enc))
+ goto junk;
id = rb_intern3(name, last, enc);
if (id > tLAST_OP_ID && !is_attrset_id(id)) {
enc = rb_enc_get(rb_id2str(id));