diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-18 05:52:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-18 05:52:40 +0000 |
commit | b493d156de6506c52222296bf0c26256d0f0479e (patch) | |
tree | 215df55e4f6dd04c6be150fbced6846ab23feede /string.c | |
parent | b8fde968619cb9116fb765c70b3295460645652f (diff) |
string.c: integer overflow
* string.c (rb_str_modify_expand): check integer overflow.
[ruby-core:75592] [Bug #12390]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -1914,6 +1914,9 @@ rb_str_modify_expand(VALUE str, long expand) else if (expand > 0) { long len = RSTRING_LEN(str); long capa = len + expand; + if (expand >= LONG_MAX - len - termlen) { + rb_raise(rb_eArgError, "string size too big"); + } if (!STR_EMBED_P(str)) { REALLOC_N(RSTRING(str)->as.heap.ptr, char, capa + termlen); RSTRING(str)->as.heap.aux.capa = capa; |