aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-01 13:39:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-01 13:39:01 +0000
commitbbe6fefbd24f49431c44ad556cca580e8644e561 (patch)
tree186308dd46fbba298839efd20e84c3444c32caf1
parent2aad7e509d8dd1cd2db16dbde9e42a38d43f1974 (diff)
downloadruby-bbe6fefbd24f49431c44ad556cca580e8644e561.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
-rw-r--r--ext/openssl/ossl_asn1.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index e43d8147e3..51f0475424 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)));