1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* time.c: raise exception when minutes of utc_offset is out of 00-59.

patch is from Kenichi Kamiya.
  [ruby-dev:47539] [Bug #8679]

* test/ruby/test_time.rb: test for above.
  patch is from Kenichi Kamiya.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
glass 2014-09-21 16:58:47 +00:00
parent a3307d5e5a
commit 5697b2f013
3 changed files with 11 additions and 0 deletions

View file

@ -1,3 +1,12 @@
Sun Sep 21 13:54:36 2014 Masaki Matsushita <glass.saga@gmail.com>
* time.c: raise exception when minutes of utc_offset is out of 00-59.
patch is from Kenichi Kamiya.
[ruby-dev:47539] [Bug #8679]
* test/ruby/test_time.rb: test for above.
patch is from Kenichi Kamiya.
Sun Sep 21 19:04:08 2014 Narihiro Nakamura <authornari@gmail.com> Sun Sep 21 19:04:08 2014 Narihiro Nakamura <authornari@gmail.com>
* st.c (do_hash_bin): unused macro. * st.c (do_hash_bin): unused macro.

View file

@ -46,6 +46,7 @@ class TestTime < Test::Unit::TestCase
tm = [2001,2,28,23,59,30] tm = [2001,2,28,23,59,30]
t = Time.new(*tm, "-12:00") t = Time.new(*tm, "-12:00")
assert_equal([2001,2,28,23,59,30,-43200], [t.year, t.month, t.mday, t.hour, t.min, t.sec, t.gmt_offset], bug4090) assert_equal([2001,2,28,23,59,30,-43200], [t.year, t.month, t.mday, t.hour, t.min, t.sec, t.gmt_offset], bug4090)
assert_raise(ArgumentError) { Time.new(2000,1,1, 0,0,0, "+01:60") }
end end
def test_time_add() def test_time_add()

1
time.c
View file

@ -2092,6 +2092,7 @@ utc_offset_arg(VALUE arg)
if (!ISDIGIT(s[1]) || !ISDIGIT(s[2])) goto invalid_utc_offset; if (!ISDIGIT(s[1]) || !ISDIGIT(s[2])) goto invalid_utc_offset;
if (s[3] != ':') goto invalid_utc_offset; if (s[3] != ':') goto invalid_utc_offset;
if (!ISDIGIT(s[4]) || !ISDIGIT(s[5])) goto invalid_utc_offset; if (!ISDIGIT(s[4]) || !ISDIGIT(s[5])) goto invalid_utc_offset;
if (s[4] > '5') goto invalid_utc_offset;
break; break;
default: default:
goto invalid_utc_offset; goto invalid_utc_offset;