Fix opt_imax() call
authorRichard Levitte <levitte@openssl.org>
Sat, 30 Jan 2016 14:39:34 +0000 (15:39 +0100)
committerRichard Levitte <levitte@openssl.org>
Sat, 30 Jan 2016 15:23:44 +0000 (16:23 +0100)
Not all architectures have a time_t defined the same way.  To make
sure we get the same result, we need to cast &checkoffset to (intmax_t *)
and make sure that intmax_t is defined somehow.

To make really sure we don't pass a variable with the wrong size down
to opt_imax(), we use a temporary intmax_t.

Reviewed-by: Rich Salz <rsalz@openssl.org>
apps/apps.h
apps/x509.c

index b6e894de39df492fa4ae54a12f2b01a78d1cdf8b..5ea148d9f3f2d8467d158a6387e7660d7641241f 100644 (file)
@@ -145,6 +145,8 @@ int opt_umax(const char *value, uintmax_t *result);
 # else
 #  define opt_imax opt_long
 #  define opt_umax opt_ulong
 # else
 #  define opt_imax opt_long
 #  define opt_umax opt_ulong
+#  define intmax_t long
+#  define uintmax_t unsigned long
 # endif
 
 int app_RAND_load_file(const char *file, int dont_warn);
 # endif
 
 int app_RAND_load_file(const char *file, int dont_warn);
index a8d0686a6bc39106e731485db448f33ae3afd474..5d6bb9679ac35199ab237f63762817e3714fc2d8 100644 (file)
@@ -468,12 +468,16 @@ int x509_main(int argc, char **argv)
             break;
         case OPT_CHECKEND:
             checkend = 1;
             break;
         case OPT_CHECKEND:
             checkend = 1;
-            if (!opt_imax(opt_arg(), &checkoffset))
-                goto opthelp;
-            if (checkoffset != (time_t)checkoffset) {
-                BIO_printf(bio_err, "%s: checkend time out of range %s\n",
-                           prog, opt_arg());
-                goto opthelp;
+            {
+                intmax_t temp = 0;
+                if (!opt_imax(opt_arg(), &temp))
+                    goto opthelp;
+                checkoffset = (time_t)temp;
+                if ((intmax_t)checkoffset != temp) {
+                    BIO_printf(bio_err, "%s: checkend time out of range %s\n",
+                               prog, opt_arg());
+                    goto opthelp;
+                }
             }
             break;
         case OPT_CHECKHOST:
             }
             break;
         case OPT_CHECKHOST: