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

ruby-changes:45724

From: nobu <ko1@a...>
Date: Tue, 7 Mar 2017 14:48:25 +0900 (JST)
Subject: [ruby-changes:45724] nobu:r57797 (trunk): string.c: fix integer overflow

nobu	2017-03-07 14:48:15 +0900 (Tue, 07 Mar 2017)

  New Revision: 57797

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

  Log:
    string.c: fix integer overflow
    
    * string.c (rb_str_subpos): fix integer overflow which can happen
      only when SHARABLE_MIDDLE_SUBSTRING is enabled.  incorpolate
      https://github.com/mruby/mruby/commit/7db0786abdd243ba031e24683f

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 57796)
+++ string.c	(revision 57797)
@@ -2386,7 +2386,7 @@ rb_str_subpos(VALUE str, long beg, long https://github.com/ruby/ruby/blob/trunk/string.c#L2386
 	    beg += blen;
 	    if (beg < 0) return 0;
 	}
-	if (beg + len > blen)
+	if (len > blen - beg)
 	    len = blen - beg;
 	if (len < 0) return 0;
 	p = s + beg;

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

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