summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-13 11:47:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-13 11:47:45 +0000
commitbd17e255889f35d0ae56e5a4d8a375310adb9ee3 (patch)
tree4660f3f9b38ceb146455f527c0e540f20701f5d4 /string.c
parentb75f68ab8d54f2c4f85a71fe129074ecb554d53a (diff)
string.c (rb_str_set_len): pathological check
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index ceab6ea42d..6390ec5227 100644
--- a/string.c
+++ b/string.c
@@ -2574,7 +2574,7 @@ rb_str_set_len(VALUE str, long len)
if (STR_SHARED_P(str)) {
rb_raise(rb_eRuntimeError, "can't set length of shared string");
}
- if (len > (capa = (long)str_capacity(str, termlen))) {
+ if (len > (capa = (long)str_capacity(str, termlen)) || len < 0) {
rb_bug("probable buffer overflow: %ld for %ld", len, capa);
}
STR_SET_LEN(str, len);