summaryrefslogtreecommitdiff
path: root/ext/stringio
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-17 23:52:48 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-17 23:52:48 (GMT)
commited4aed86fbfdc8133148c6ffa2e03312a601a3cd (patch)
treee9e5429892ff1dfe7a135b3d22dceca163f65f7c /ext/stringio
parent34eb16651e2809bec19523b989aafb987022aac8 (diff)
stringio.c: fix index overflow
* ext/stringio/stringio.c (strio_getline): fix pointer index overflow. reported by Guido Vranken <guido AT guidovranken.nl>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/stringio')
-rw-r--r--ext/stringio/stringio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 4fdc4df..f35c702 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -1021,7 +1021,7 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr)
s = RSTRING_PTR(ptr->string);
e = s + RSTRING_LEN(ptr->string);
s += ptr->pos;
- if (limit > 0 && s + limit < e) {
+ if (limit > 0 && (size_t)limit < (size_t)(e - s)) {
e = rb_enc_right_char_head(s, s + limit, e, get_enc(ptr));
}
if (NIL_P(str)) {