Project

General

Profile

Bug #4571

YAML.load given an ISO8601 timestamp creates an incorrect value for usec

Added by brixen (Brian Shirai) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
-
Backport:
[ruby-core:35713]

Description

=begin
$ ruby1.8.7 -v -ryaml -e 'p YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec'
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin9.8.0]
342222

$ ruby1.9.2 -v -ryaml -e 'p YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec'
ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-darwin9.8.0]
342222

$ ruby1.9 -v -ryaml -e 'p YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec'
ruby 1.9.3dev (2011-04-12 trunk 31263) [i386-darwin9.8.0]
342222

I believe these should be 0.

Thanks,
Brian
=end


Files

noname (500 Bytes) noname tenderlovemaking (Aaron Patterson), 05/06/2011 08:23 AM

Associated revisions

Revision dbbfac20
Added by shyouhei (Shyouhei Urabe) over 8 years ago

YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 31441
Added by shyouhei (Shyouhei Urabe) over 8 years ago

YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

Revision 31441
Added by shyouhei (Shyouhei Urabe) over 8 years ago

YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

Revision 31441
Added by shyouhei (Shyouhei Urabe) over 8 years ago

YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

Revision 31441
Added by shyouhei (Shyouhei Urabe) over 8 years ago

YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

Revision 31441
Added by shyouhei (Shyouhei Urabe) over 8 years ago

YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

Revision 31441
Added by shyouhei (Shyouhei Urabe) over 8 years ago

YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

Revision eff01662
Added by yugui (Yuki Sonoda) over 8 years ago

merges r31441,r31442 and r31443 from trunk into ruby_1_9_2.

YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

ChangeLog for it

  • ext/syck/rubyext.c (mktime_do): avoid buffer overrun, by silently ignoring lesser significant digits. Required buffer length can be computable so you might at first think of allocating enough memory space on the fly using alloca(). That is a wrong idea because when using alloca there is always risk of integer overflow. A function that accepts outer-process resources like this should not blindly trust its inputs. In this particular case we just want to generate miliseconds resolution by strtod() so the string in question needs no more length than what we originally have. Ignoring lesser significant digits should suffice I believe.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

Updated by naruse (Yui NARUSE) over 8 years ago

  • Category set to ext
  • Status changed from Open to Assigned
  • Assignee set to tenderlovemaking (Aaron Patterson)

=begin

=end

Updated by d-snp (Tinco Andringa) over 8 years ago

I have submitted a pull request for this bug:

https://github.com/ruby/ruby/pull/15

Updated by shyouhei (Shyouhei Urabe) over 8 years ago

Hi Aaron, how do you feel the patch?

I can pull it when you are OK.

Updated by tenderlovemaking (Aaron Patterson) over 8 years ago

  • ruby -v changed from ruby 1.9.3dev (2011-04-12 trunk 31263) [i386-darwin9.8.0] to -

On Thu, May 05, 2011 at 11:31:14AM +0900, Shyouhei Urabe wrote:

Issue #4571 has been updated by Shyouhei Urabe.

Hi Aaron, how do you feel the patch?

I can pull it when you are OK.

It seems good to me. Please merge it in!

--
Aaron Patterson
http://tenderlovemaking.com/

#5

Updated by shyouhei (Shyouhei Urabe) over 8 years ago

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

This issue was solved with changeset r31441.
Brian, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


YAML.load time correctly parse usecs smaller than 1 fixes #4571

Signed-off-by: URABE, Shyouhei shyouhei@ruby-lang.org

Also available in: Atom PDF