[前][次][番号順一覧][スレッド一覧]

ruby-changes:43178

From: nobu <ko1@a...>
Date: Wed, 1 Jun 2016 22:39:08 +0900 (JST)
Subject: [ruby-changes:43178] nobu:r55252 (trunk): ossl_asn1.c: check overflow

nobu	2016-06-01 22:39:01 +0900 (Wed, 01 Jun 2016)

  New Revision: 55252

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55252

  Log:
    ossl_asn1.c: check overflow
    
    * ext/openssl/ossl_asn1.c (ossl_time_split): check overflow and
      reorder for optimization.

  Modified files:
    trunk/ext/openssl/ossl_asn1.c
Index: ext/openssl/ossl_asn1.c
===================================================================
--- ext/openssl/ossl_asn1.c	(revision 55251)
+++ ext/openssl/ossl_asn1.c	(revision 55252)
@@ -82,8 +82,9 @@ ossl_time_split(VALUE time, time_t *sec, https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_asn1.c#L82
     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)));

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]