Bug #4221

Unexpected result of Time#strftime("%s") on Windows with trunk

Added by Heesob Park over 3 years ago. Updated almost 3 years ago.

[ruby-core:33985]
Status:Closed
Priority:Normal
Assignee:-
Category:core
Target version:1.9.3
ruby -v:ruby 1.9.3dev (2010-12-28 trunk 30412) [i386-mswin32_90] Backport:

Description

=begin
C:\work>irb
irb(main):001:0> Time.at(2000000000).strftime('%s')
=> "2000000000"
irb(main):002:0> Time.at(3000000000).strftime('%s')
=> "/.',').'"
irb(main):003:0> Time.at(4000000000).strftime('%s')
=> ".',').'"
irb(main):004:0> Time.at(5000000000).strftime('%s')
=> "705032704"
=end

History

#1 Updated by Peter Weldon over 3 years ago

=begin
Most likely an overflow bug:

irb(main):001:0> Time.at(231 - 1).strftime('%s')
=> "2147483647"
irb(main):002:0> Time.at(2
31).strftime('%s')
=> "./,),(-,("
irb(main):003:0> Time.at(2
32).strftime('%s')
=> "0"
irb(main):004:0> Time.at(2
*32 + 1).strftime('%s')
=> "1"
=end

#2 Updated by Peter Weldon over 3 years ago

=begin
From 8155b4d68f5b09ad95da23db499cd718be38fd29 Mon Sep 17 00:00:00 2001
From: Peter Weldon peter.weldon@null.net
Date: Wed, 29 Dec 2010 12:32:30 -0800
Subject: [PATCH] vsnprintf.c (BSD_uqtoa): Fix overflow when long != quadt


vsnprintf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/vsnprintf.c b/vsnprintf.c
index 7576b4c..648904f 100644
--- a/vsnprintf.c
+++ b/vsnprintf.c
@@ -368,7 +368,7 @@ static char *
BSD_uqtoa(register uquadt 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

--
1.7.1.msysgit.0
=end

#3 Updated by Yui NARUSE over 3 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r30435.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF