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

ruby-changes:42369

From: nagachika <ko1@a...>
Date: Thu, 31 Mar 2016 05:16:26 +0900 (JST)
Subject: [ruby-changes:42369] nagachika:r54443 (ruby_2_2): merge revision(s) 54304: [Backport #12223]

nagachika	2016-03-31 05:16:19 +0900 (Thu, 31 Mar 2016)

  New Revision: 54443

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

  Log:
    merge revision(s) 54304: [Backport #12223]
    
    * sprintf.c (rb_str_format): fix buffer overflow, length must be
      greater than precision.  reported by William Bowling <will AT
      wbowling.info>.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/sprintf.c
    branches/ruby_2_2/test/ruby/test_sprintf.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 54442)
+++ ruby_2_2/version.h	(revision 54443)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.5"
 #define RUBY_RELEASE_DATE "2016-03-31"
-#define RUBY_PATCHLEVEL 291
+#define RUBY_PATCHLEVEL 292
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 54442)
+++ ruby_2_2/ChangeLog	(revision 54443)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Thu Mar 31 05:06:02 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* sprintf.c (rb_str_format): fix buffer overflow, length must be
+	  greater than precision.  reported by William Bowling <will AT
+	  wbowling.info>.
+
 Thu Mar 31 04:49:05 2016  Kimura Wataru  <kimuraw@i...>
 
 	* test/ruby/test_io.rb: handled rlimit value same as r52277
Index: ruby_2_2/test/ruby/test_sprintf.rb
===================================================================
--- ruby_2_2/test/ruby/test_sprintf.rb	(revision 54442)
+++ ruby_2_2/test/ruby/test_sprintf.rb	(revision 54443)
@@ -171,6 +171,10 @@ class TestSprintf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_sprintf.rb#L171
     assert_equal("x"*10+"     1.0", sprintf("x"*10+"%8.1f", 1r))
   end
 
+  def test_rational_precision
+    assert_match(/\A0\.\d{600}\z/, sprintf("%.600f", 600**~60))
+  end
+
   def test_hash
     options = {:capture=>/\d+/}
     assert_equal("with options {:capture=>/\\d+/}", sprintf("with options %p" % options))
Index: ruby_2_2/sprintf.c
===================================================================
--- ruby_2_2/sprintf.c	(revision 54442)
+++ ruby_2_2/sprintf.c	(revision 54443)
@@ -1055,7 +1055,7 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/ruby_2_2/sprintf.c#L1055
 		}
 		val = rb_obj_as_string(num);
 		len = RSTRING_LEN(val) + zero;
-		if (prec >= len) ++len; /* integer part 0 */
+		if (prec >= len) len = prec + 1; /* integer part 0 */
 		if (sign || (flags&FSPACE)) ++len;
 		if (prec > 0) ++len; /* period */
 		CHECK(len > width ? len : width);

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r54304


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

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