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

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
This commit is contained in:
nobu 2016-06-01 13:39:01 +00:00
parent 5f225f3114
commit 2fe605911c

View file

@ -82,8 +82,9 @@ ossl_time_split(VALUE time, time_t *sec, int *days)
VALUE num = rb_Integer(time); VALUE num = rb_Integer(time);
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
*days = FIX2LONG(num) / 86400; time_t t = FIX2LONG(num);
*sec = FIX2LONG(num) % 86400; *sec = t % 86400;
*days = rb_long2int(t / 86400);
} }
else { else {
*days = NUM2INT(rb_funcall(num, rb_intern("/"), 1, INT2FIX(86400))); *days = NUM2INT(rb_funcall(num, rb_intern("/"), 1, INT2FIX(86400)));