1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
kosaki 2011-08-07 14:38:17 +00:00
parent 9c760d0aad
commit f2f14f572d
3 changed files with 16 additions and 1 deletions

View file

@ -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.

View file

@ -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

6
time.c
View file

@ -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;
}