From 3d38ba877eb14cc4d6b711e41d64953b366a502b Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 30 Dec 2010 18:53:41 +0000 Subject: [PATCH] * vsnprintf.c (BSD__uqtoa): Fix overflow when long != quad_t. patched by Peter Weldon [ruby-core:33985] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_time.rb | 3 +++ vsnprintf.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a13342cb3e..fc37ac9de2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Dec 31 03:23:26 2010 NARUSE, Yui + + * vsnprintf.c (BSD__uqtoa): Fix overflow when long != quad_t. + patched by Peter Weldon + [ruby-core:33985] + Fri Dec 31 03:00:34 2010 Kazuhiro NISHIYAMA * Makefile.in: remove unnecessary semicolons. diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 8c96a0d2cd..ec5395092f 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -634,6 +634,9 @@ class TestTime < Test::Unit::TestCase t.strftime("%m/%d/%Y %l:%M:%S.%9N")) assert_equal("03/14/1592 6:53:58.97932384", t.strftime("%m/%d/%Y %l:%M:%S.%8N")) + + # [ruby-core:33985] + assert_equal("3000000000", Time.at(3000000000).strftime('%s')) end def test_delegate diff --git a/vsnprintf.c b/vsnprintf.c index 7576b4c5b4..648904f795 100644 --- a/vsnprintf.c +++ b/vsnprintf.c @@ -368,7 +368,7 @@ static char * BSD__uqtoa(register u_quad_t val, char *endp, int base, int octzero, const char *xdigs) { register char *cp = endp; - register long sval; + register quad_t sval; /* * Handle the three cases separately, in the hope of getting