Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* 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
  • Loading branch information...
commit f2f14f572d6fb92394955953352e6edb688cc986 1 parent 9c760d0
@kosaki kosaki authored
Showing with 16 additions and 1 deletion.
  1. +8 −0 ChangeLog
  2. +3 −0  test/ruby/test_time.rb
  3. +5 −1 time.c
View
8 ChangeLog
@@ -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
3  test/ruby/test_time.rb
@@ -650,6 +650,9 @@ def test_strftime
# [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
View
6 time.c
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.