Project

General

Profile

Actions

Bug #4221

closed

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

Added by phasis68 (Heesob Park) over 13 years ago. Updated almost 13 years ago.

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

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

Actions #1

Updated by pweldon (Peter Weldon) over 13 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(232).strftime('%s')
=> "0"
irb(main):004:0> Time.at(2
32 + 1).strftime('%s')
=> "1"
=end

Actions #2

Updated by pweldon (Peter Weldon) over 13 years ago

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


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

--
1.7.1.msysgit.0
=end

Actions #3

Updated by naruse (Yui NARUSE) over 13 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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0