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

ruby-changes:20837

From: kosaki <ko1@a...>
Date: Sun, 7 Aug 2011 23:40:33 +0900 (JST)
Subject: [ruby-changes:20837] kosaki:r32886 (ruby_1_9_3): merge revision(s) 32885:

kosaki	2011-08-07 23:40:07 +0900 (Sun, 07 Aug 2011)

  New Revision: 32886

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32886

  Log:
    merge revision(s) 32885:
    
    * time.c (rb_strftime_alloc): raise ERANGE if width is too large.
      Patch by Nobuyoshi Nakada. [Bug #4457] [ruby-dev:43285]
    
    * test/ruby/test_time.rb (class TestTime): add a test for the
      above change.

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/test/ruby/test_time.rb
    branches/ruby_1_9_3/time.c

Index: ruby_1_9_3/time.c
===================================================================
--- ruby_1_9_3/time.c	(revision 32885)
+++ ruby_1_9_3/time.c	(revision 32886)
@@ -4326,8 +4326,12 @@
 	 * if the buffer is 1024 times bigger than the length of the
 	 * format string, it's not failing for lack of room.
 	 */
-	if (len > 0 || size >= 1024 * flen) break;
+	if (len > 0) break;
 	xfree(*buf);
+	if (size >= 1024 * flen) {
+	    rb_sys_fail(format);
+	    break;
+	}
     }
     return len;
 }
Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 32885)
+++ ruby_1_9_3/ChangeLog	(revision 32886)
@@ -1,3 +1,11 @@
+Sun Aug  7 23:39:44 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* time.c (rb_strftime_alloc): raise ERANGE if width is too large.
+	  Patch by Nobuyoshi Nakada. [Bug #4457] [ruby-dev:43285]
+
+	* test/ruby/test_time.rb (class TestTime): add a test for the
+	  above change.
+
 Sun Aug  7 14:15:10 2011  Kazuki Tsujimoto  <kazuki@c...>
 
 	* backport r32876 from trunk.
Index: ruby_1_9_3/test/ruby/test_time.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_time.rb	(revision 32885)
+++ ruby_1_9_3/test/ruby/test_time.rb	(revision 32886)
@@ -649,6 +649,9 @@
 
     # [ruby-core:33985]
     assert_equal("3000000000", Time.at(3000000000).strftime('%s'))
+
+    bug4457 = '[ruby-dev:43285]'
+    assert_raise(Errno::ERANGE, bug4457) {Time.now.strftime('%8192z')}
   end
 
   def test_delegate

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

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