[前][次][番号順一覧][スレッド一覧]

ruby-changes:45726

From: nobu <ko1@a...>
Date: Tue, 7 Mar 2017 18:08:01 +0900 (JST)
Subject: [ruby-changes:45726] nobu:r57799 (trunk): string.c: fix integer overflow

nobu	2017-03-07 18:07:57 +0900 (Tue, 07 Mar 2017)

  New Revision: 57799

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57799

  Log:
    string.c: fix integer overflow
    
    * string.c (str_byte_substr): fix another integer overflow which
      can happen only when SHARABLE_MIDDLE_SUBSTRING is enabled.
      [ruby-core:79951] [Bug #13289]

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 57798)
+++ string.c	(revision 57799)
@@ -5254,7 +5254,7 @@ str_byte_substr(VALUE str, long beg, lon https://github.com/ruby/ruby/blob/trunk/string.c#L5254
 	beg += n;
 	if (beg < 0) return Qnil;
     }
-    if (beg + len > n)
+    if (len > n - beg)
 	len = n - beg;
     if (len <= 0) {
 	if (!empty) return Qnil;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]