diff options
author | nobu <nobu@ruby-lang.org> | 2016-06-01 13:39:01 +0000 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-06-09 15:05:21 +0900 |
commit | 5fdb6845f3604cc6358405739962dc69b525a3a8 (patch) | |
tree | fefe83f1a705e3c59315d8b2dcd3369b565c8923 /ext/openssl/ossl_asn1.c | |
parent | 1263d94bb8458481d1d8b034dc30d4d53dca10ea (diff) | |
download | ruby-openssl-5fdb6845f3604cc6358405739962dc69b525a3a8.tar.gz |
ossl_asn1.c: check overflow
* ext/openssl/ossl_asn1.c (ossl_time_split): check overflow and
reorder for optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_asn1.c')
-rw-r--r-- | ext/openssl/ossl_asn1.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index e43d8147..51f04754 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -82,8 +82,9 @@ ossl_time_split(VALUE time, time_t *sec, int *days) VALUE num = rb_Integer(time); if (FIXNUM_P(num)) { - *days = FIX2LONG(num) / 86400; - *sec = FIX2LONG(num) % 86400; + time_t t = FIX2LONG(num); + *sec = t % 86400; + *days = rb_long2int(t / 86400); } else { *days = NUM2INT(rb_funcall(num, rb_intern("/"), 1, INT2FIX(86400))); |