diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-07 14:40:07 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-07 14:40:07 +0000 |
commit | 4a5a6f4a2c6a20fb61ab834655fdae8ba4879196 (patch) | |
tree | e18fe99e6a2e828026bc38d6e952605509ffebcf | |
parent | 86411a0a761976b6d4ec9d0d841e727f17495c78 (diff) |
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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32886 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:39:44 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 14:15:10 2011 Kazuki Tsujimoto <kazuki@callcc.net> * backport r32876 from trunk. diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index aea4c2edc0..0e61f32ab0 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -649,6 +649,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 @@ -4326,8 +4326,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; } |