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

ruby-changes:42431

From: nagachika <ko1@a...>
Date: Thu, 7 Apr 2016 00:19:23 +0900 (JST)
Subject: [ruby-changes:42431] nagachika:r54505 (ruby_2_3): merge revision(s) 54304: [Backport #12223]

nagachika	2016-04-07 01:15:59 +0900 (Thu, 07 Apr 2016)

  New Revision: 54505

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

  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_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/sprintf.c
    branches/ruby_2_3/test/ruby/test_sprintf.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/test/ruby/test_sprintf.rb
===================================================================
--- ruby_2_3/test/ruby/test_sprintf.rb	(revision 54504)
+++ ruby_2_3/test/ruby/test_sprintf.rb	(revision 54505)
@@ -172,6 +172,10 @@ class TestSprintf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_sprintf.rb#L172
     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_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 54504)
+++ ruby_2_3/version.h	(revision 54505)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.0"
-#define RUBY_RELEASE_DATE "2016-04-06"
-#define RUBY_PATCHLEVEL 74
+#define RUBY_RELEASE_DATE "2016-04-07"
+#define RUBY_PATCHLEVEL 75
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 4
-#define RUBY_RELEASE_DAY 6
+#define RUBY_RELEASE_DAY 7
 
 #include "ruby/version.h"
 
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 54504)
+++ ruby_2_3/ChangeLog	(revision 54505)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Thu Apr  7 01:07: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>.
+
 Wed Apr  6 00:33:45 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/rubygems/security.rb (DIGEST_ALGORITHM, KEY_ALGORITHM):
Index: ruby_2_3/sprintf.c
===================================================================
--- ruby_2_3/sprintf.c	(revision 54504)
+++ ruby_2_3/sprintf.c	(revision 54505)
@@ -1067,7 +1067,7 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/ruby_2_3/sprintf.c#L1067
 		}
 		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_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r54304


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

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