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

ruby-changes:45267

From: nagachika <ko1@a...>
Date: Tue, 17 Jan 2017 03:40:28 +0900 (JST)
Subject: [ruby-changes:45267] nagachika:r57340 (ruby_2_3): merge revision(s) 57108: [Backport #13121]

nagachika	2017-01-17 03:40:22 +0900 (Tue, 17 Jan 2017)

  New Revision: 57340

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

  Log:
    merge revision(s) 57108: [Backport #13121]
    
    sprintf.c: fix width underflow
    
    * sprintf.c (rb_str_format): fix memory corruption by width
      underflow.  https://github.com/mruby/mruby/issues/3347

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    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/sprintf.c
===================================================================
--- ruby_2_3/sprintf.c	(revision 57339)
+++ ruby_2_3/sprintf.c	(revision 57340)
@@ -697,10 +697,10 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/ruby_2_3/sprintf.c#L697
 		    CHECK(n);
 		    rb_enc_mbcput(c, &buf[blen], enc);
 		    blen += n;
-		    FILL(' ', width-1);
+		    if (width > 1) FILL(' ', width-1);
 		}
 		else {
-		    FILL(' ', width-1);
+		    if (width > 1) FILL(' ', width-1);
 		    CHECK(n);
 		    rb_enc_mbcput(c, &buf[blen], enc);
 		    blen += n;
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 57339)
+++ ruby_2_3/version.h	(revision 57340)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.3"
-#define RUBY_RELEASE_DATE "2016-11-24"
-#define RUBY_PATCHLEVEL 224
+#define RUBY_RELEASE_DATE "2017-01-17"
+#define RUBY_PATCHLEVEL 225
 
-#define RUBY_RELEASE_YEAR 2016
-#define RUBY_RELEASE_MONTH 11
-#define RUBY_RELEASE_DAY 24
+#define RUBY_RELEASE_YEAR 2017
+#define RUBY_RELEASE_MONTH 1
+#define RUBY_RELEASE_DAY 17
 
 #include "ruby/version.h"
 
Index: ruby_2_3/test/ruby/test_sprintf.rb
===================================================================
--- ruby_2_3/test/ruby/test_sprintf.rb	(revision 57339)
+++ ruby_2_3/test/ruby/test_sprintf.rb	(revision 57340)
@@ -433,4 +433,9 @@ class TestSprintf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_sprintf.rb#L433
     h = { key: nil, key2: "key2_val" }
     assert_equal("key is , key2 is key2_val", "key is %{key}, key2 is %{key2}" % h)
   end
+
+  def test_width_underflow
+    bug = 'https://github.com/mruby/mruby/issues/3347'
+    assert_equal("!", sprintf("%*c", 0, ?!.ord), bug)
+  end
 end

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57108


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

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