diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-07 14:38:17 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-07 14:38:17 +0000 |
commit | f2f14f572d6fb92394955953352e6edb688cc986 (patch) | |
tree | 5c9ba4dad1d98cb1b01ce1b84c94d1c1b677fc63 | |
parent | 9c760d0aad3fac021dcfa7d7c80609cd4178d9c9 (diff) | |
download | ruby-f2f14f572d6fb92394955953352e6edb688cc986.tar.gz |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | test/ruby/test_time.rb | 3 | ||||
-rw-r--r-- | time.c | 6 |
3 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,11 @@ +Sun Aug 7 23:31:32 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * 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@gmail.com> * ext/openssl/ossl_asn1.c (decode_eoc): remove unused variables. diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 38e567a703..1f07a8249c 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -650,6 +650,9 @@ class TestTime < Test::Unit::TestCase # [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 @@ -4325,8 +4325,12 @@ rb_strftime_alloc(char **buf, const char *format, * 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; } |