aboutsummaryrefslogtreecommitdiffstats
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
commite57289d2084f97f13534e060c05204bff47c7b8a (patch)
tree4660f3f9b38ceb146455f527c0e540f20701f5d4 /string.c
parent56260ece997c1b628a4e4e4403e6624e9a888aa9 (diff)
downloadruby-e57289d2084f97f13534e060c05204bff47c7b8a.tar.gz
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);