From a45e38e962a30307dd2034c2c032bd76333ebd2c Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sat, 17 Oct 2015 22:57:59 -0500 Subject: disable some tests with 32-bit time_t systems Also disable use of _mkgmtime, it does not produce correct results. --- configure.ac | 3 ++ crypto/Makefile.am | 2 -- include/compat/time.h | 4 --- m4/check-libc.m4 | 1 - patches/rfc5280.c.patch | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 patches/rfc5280.c.patch diff --git a/configure.ac b/configure.ac index c103399..e97991d 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,9 @@ AM_CONDITIONAL([BUILD_CERTHASH], [test "x$ac_cv_func_symlink" = xyes]) # Check if funopen exists AC_CHECK_FUNC([funopen]) +# Check if time_t is sized correctly +AC_CHECK_SIZEOF([time_t], [time.h]) + CHECK_LIBC_COMPAT CHECK_SYSCALL_COMPAT CHECK_CRYPTO_COMPAT diff --git a/crypto/Makefile.am b/crypto/Makefile.am index 40d82cd..b5ccf24 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am @@ -74,10 +74,8 @@ libcompat_la_SOURCES += compat/inet_pton.c endif if !HAVE_TIMEGM -if !HAVE__MKGMTIME libcompat_la_SOURCES += compat/timegm.c endif -endif if !HAVE_REALLOCARRAY libcompat_la_SOURCES += compat/reallocarray.c diff --git a/include/compat/time.h b/include/compat/time.h index 3a87548..9ed9c03 100644 --- a/include/compat/time.h +++ b/include/compat/time.h @@ -15,9 +15,5 @@ #endif #ifndef HAVE_TIMEGM -#ifdef HAVE__MKGMTIME -#define timegm(tm) _mkgmtime(tm) -#else time_t timegm(struct tm *tm); #endif -#endif diff --git a/m4/check-libc.m4 b/m4/check-libc.m4 index 3efc686..6a23e35 100644 --- a/m4/check-libc.m4 +++ b/m4/check-libc.m4 @@ -17,7 +17,6 @@ AM_CONDITIONAL([HAVE_STRNLEN], [test "x$ac_cv_func_strnlen" = xyes]) AM_CONDITIONAL([HAVE_STRSEP], [test "x$ac_cv_func_strsep" = xyes]) AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes]) AM_CONDITIONAL([HAVE_TIMEGM], [test "x$ac_cv_func_timegm" = xyes]) -AM_CONDITIONAL([HAVE__MKGMTIME], [test "x$ac_cv_func__mkgmtime" = xyes]) ]) AC_DEFUN([CHECK_SYSCALL_COMPAT], [ diff --git a/patches/rfc5280.c.patch b/patches/rfc5280.c.patch new file mode 100644 index 0000000..4281109 --- /dev/null +++ b/patches/rfc5280.c.patch @@ -0,0 +1,82 @@ +--- tests/rfc5280time.c.orig Sat Oct 17 22:36:27 2015 ++++ tests/rfc5280time.c Sat Oct 17 22:44:25 2015 +@@ -91,6 +91,7 @@ + .data = "20150923032700Z", + .time = 1442978820, + }, ++#if SIZEOF_TIME_T == 8 + { + /* (times before 2050 must be UTCTIME) Per RFC 5280 4.1.2.5 */ + .str = "00000101000000Z", +@@ -103,6 +104,7 @@ + .data = "20491231235959Z", + .time = 2524607999, + }, ++#endif + { + /* (times before 2050 must be UTCTIME) Per RFC 5280 4.1.2.5 */ + .str = "19500101000000Z", +@@ -112,6 +114,7 @@ + }; + + struct rfc5280_time_test rfc5280_gentime_tests[] = { ++#if SIZEOF_TIME_T == 8 + { + /* Biggest RFC 5280 time */ + .str = "99991231235959Z", +@@ -129,6 +132,7 @@ + .data = "20500101000000Z", + .time = 2524608000, + }, ++#endif + }; + struct rfc5280_time_test rfc5280_utctime_tests[] = { + { +@@ -141,11 +145,13 @@ + .data = "540226230640Z", + .time = -500000000, + }, ++#if SIZEOF_TIME_T == 8 + { + .str = "491231235959Z", + .data = "491231235959Z", + .time = 2524607999, + }, ++#endif + { + .str = "700101000000Z", + .data = "700101000000Z", +@@ -273,14 +279,14 @@ + + if ((i = X509_cmp_time(gt, &att->time)) != -1) { + fprintf(stderr, "FAIL: test %i - X509_cmp_time failed - returned %d compared to %lld\n", +- test_no, i, att->time); ++ test_no, i, (long long)att->time); + goto done; + } + + att->time--; + if ((i = X509_cmp_time(gt, &att->time)) != 1) { + fprintf(stderr, "FAIL: test %i - X509_cmp_time failed - returned %d compared to %lld\n", +- test_no, i, att->time); ++ test_no, i, (long long)att->time); + goto done; + } + att->time++; +@@ -325,14 +331,14 @@ + + if ((i = X509_cmp_time(ut, &att->time)) != -1) { + fprintf(stderr, "FAIL: test %i - X509_cmp_time failed - returned %d compared to %lld\n", +- test_no, i, att->time); ++ test_no, i, (long long)att->time); + goto done; + } + + att->time--; + if ((i = X509_cmp_time(ut, &att->time)) != 1) { + fprintf(stderr, "FAIL: test %i - X509_cmp_time failed - returned %d compared to %lld\n", +- test_no, i, att->time); ++ test_no, i, (long long)att->time); + goto done; + } + att->time++; -- cgit v1.2.3-55-g6feb