]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Add configure-time detection for SSH_TIME_T_MAX.
authorDarren Tucker <dtucker@dtucker.net>
Mon, 12 Jul 2021 08:00:05 +0000 (18:00 +1000)
committerDarren Tucker <dtucker@dtucker.net>
Mon, 12 Jul 2021 08:21:26 +0000 (18:21 +1000)
Should fix printing cert times exceeding INT_MAX (bz#3329) on platforms
were time_t is a long long.  The limit used is for the signed type, so if
some system has a 32bit unsigned time_t then the lower limit will still
be imposed and we would need to add some way to detect this.  Anyone using
an unsigned 64bit can let us know when it starts being a problem.

configure.ac
defines.h
misc.c

index 83719193d24a0a5fe8b4527f9cf3d72690e224e7..e728e323610204e3b715800fca96a2cdec56af12 100644 (file)
@@ -3664,7 +3664,7 @@ if test ! -z "$SONY" ; then
   LIBS="$LIBS -liberty";
 fi
 
-# Check for  long long datatypes
+# Check for long long datatypes
 AC_CHECK_TYPES([long long, unsigned long long, long double])
 
 # Check datatype sizes
@@ -3672,6 +3672,16 @@ AC_CHECK_SIZEOF([short int])
 AC_CHECK_SIZEOF([int])
 AC_CHECK_SIZEOF([long int])
 AC_CHECK_SIZEOF([long long int])
+AC_CHECK_SIZEOF([time_t], [], [[
+    #include <sys/types.h>
+    #ifdef HAVE_SYS_TIME_H
+    # include <sys/time.h>
+    #endif
+    #ifdef HAVE_TIME_H
+    # include <time.h>
+    #endif
+       ]]
+)
 
 # Sanity check long long for some platforms (AIX)
 if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
index d6a1d014cab9d68e2da4b3c8ce1e6e7049fc5232..7fff562c0e45b2117337a7bc1c30fa29c5cb27f2 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -304,6 +304,12 @@ typedef long long intmax_t;
 typedef unsigned long long uintmax_t;
 #endif
 
+#if SIZEOF_TIME_T == SIZEOF_LONG_LONG_INT
+# define SSH_TIME_T_MAX LLONG_MAX
+#else
+# define SSH_TIME_T_MAX INT_MAX
+#endif
+
 #ifndef HAVE_U_CHAR
 typedef unsigned char u_char;
 # define HAVE_U_CHAR
diff --git a/misc.c b/misc.c
index 266e96737ff607bdd546d61aa27766b6908b84c0..adfe903371358a145df90d1f8769f1f2a37520b2 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -2384,7 +2384,7 @@ parse_absolute_time(const char *s, uint64_t *tp)
 }
 
 /* On OpenBSD time_t is int64_t which is long long. */
-#define SSH_TIME_T_MAX LLONG_MAX
+/* #define SSH_TIME_T_MAX LLONG_MAX */
 
 void
 format_absolute_time(uint64_t t, char *buf, size_t len)