ruby-changes:20836
From: kosaki <ko1@a...>
Date: Sun, 7 Aug 2011 23:38:42 +0900 (JST)
Subject: [ruby-changes:20836] kosaki:r32885 (trunk): * time.c (rb_strftime_alloc): raise ERANGE if width is too large.
kosaki 2011-08-07 23:38:17 +0900 (Sun, 07 Aug 2011) New Revision: 32885 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32885 Log: * 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: trunk/ChangeLog trunk/test/ruby/test_time.rb trunk/time.c Index: time.c =================================================================== --- time.c (revision 32884) +++ time.c (revision 32885) @@ -4325,8 +4325,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: ChangeLog =================================================================== --- ChangeLog (revision 32884) +++ ChangeLog (revision 32885) @@ -1,3 +1,11 @@ +Sun Aug 7 23:31:32 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 22:51:45 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * ext/openssl/ossl_asn1.c (decode_eoc): remove unused variables. Index: test/ruby/test_time.rb =================================================================== --- test/ruby/test_time.rb (revision 32884) +++ test/ruby/test_time.rb (revision 32885) @@ -650,6 +650,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/