diff --git a/ChangeLog b/ChangeLog index 2e6e7ccb3..c1a9473c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-10-27 Werner Koch + + * acinclude.m4 (GNUPG_TIME_T_UNSIGNED): New. + * configure.ac: Call AC_HEADER_TIME and GNUPG_TIME_T_UNSIGNED. + 2010-10-18 Werner Koch Release 1.4.11. diff --git a/THANKS b/THANKS index 4e2bca6bd..ae64d9fa9 100644 --- a/THANKS +++ b/THANKS @@ -93,6 +93,7 @@ Jan Krueger max@physics.otago.ac.nz Jan Niehusmann jan@gondor.com Janusz A. Urbanowicz alex@bofh.torun.pl James Troup james@nocrew.org +Jason Woodward jason dot woodward at timesys dot com Jean-loup Gailly gzip@prep.ai.mit.edu Jeff Long long@kestrel.cc.ukans.edu Jeffery Von Ronne jronne@ics.uci.edu diff --git a/acinclude.m4 b/acinclude.m4 index 71657dc0e..9e4a166f2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -45,6 +45,33 @@ AC_DEFUN([GNUPG_CHECK_TYPEDEF], ]) +# GNUPG_TIME_T_UNSIGNED +# Check whether time_t is unsigned +# +AC_DEFUN([GNUPG_TIME_T_UNSIGNED], + [ AC_CACHE_CHECK(whether time_t is unsigned, gnupg_cv_time_t_unsigned, + [AC_REQUIRE([AC_HEADER_TIME])dnl + AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY( + [AC_INCLUDES_DEFAULT([]) +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +], + [((time_t)-1) < 0])], + gnupg_cv_time_t_unsigned=no, gnupg_cv_time_t_unsigned=yes)]) + if test $gnupg_cv_time_t_unsigned = yes; then + AC_DEFINE(HAVE_UNSIGNED_TIME_T,1,[Defined if time_t is an unsigned type]) + fi +])# GNUPG_TIME_T_UNSIGNED + + dnl GNUPG_CHECK_GNUMAKE dnl AC_DEFUN([GNUPG_CHECK_GNUMAKE], diff --git a/configure.ac b/configure.ac index 87b38a363..8c48a24fc 100644 --- a/configure.ac +++ b/configure.ac @@ -956,6 +956,7 @@ AC_CHECK_SIZEOF(unsigned short) AC_CHECK_SIZEOF(unsigned int) AC_CHECK_SIZEOF(unsigned long) AC_CHECK_SIZEOF(unsigned long long) +AC_HEADER_TIME AC_CHECK_SIZEOF(time_t,,[[ #include #if TIME_WITH_SYS_TIME @@ -969,6 +970,7 @@ AC_CHECK_SIZEOF(time_t,,[[ # endif #endif ]]) +GNUPG_TIME_T_UNSIGNED # Ensure that we have UINT64_C before we bother to check for uint64_t AC_CHECK_HEADERS([inttypes.h]) diff --git a/g10/ChangeLog b/g10/ChangeLog index abf2084c6..e15ed8dd1 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,10 @@ +2010-10-27 Werner Koch + + * keygen.c (ask_expire_interval): Print 2038 warning only for 32 + bit signed time_t. + * keyid.c (mk_datestr): Do the y2038 test only for a signed time_t. + (INVALID_TIME_CHECK): New. + 2010-10-20 Werner Koch * encr-data.c (decode_filter): Cast -1 to size_t. Reported by diff --git a/g10/keygen.c b/g10/keygen.c index 760e63a08..8e396ce9b 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -1789,7 +1789,7 @@ ask_expire_interval(u32 timestamp,int object,const char *def_expire) ? _("Key expires at %s\n") : _("Signature expires at %s\n"), asctimestamp((ulong)(timestamp + interval) ) ); -#if SIZEOF_TIME_T <= 4 +#if SIZEOF_TIME_T <= 4 && !defined(HAVE_UNSIGNED_TIME_T) if ((time_t)((ulong)(timestamp+interval)) < 0 ) tty_printf (_("Your system can't display dates beyond 2038.\n" "However, it will be correctly handled up to" diff --git a/g10/keyid.c b/g10/keyid.c index f2657f3a5..57e9fc8e9 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -33,6 +33,14 @@ #include "keydb.h" #include "i18n.h" +#ifdef HAVE_UNSIGNED_TIME_T +# define INVALID_TIME_CHECK(a) ((a) == (time_t)(-1)) +#else + /* Error or 32 bit time_t and value after 2038-01-19. */ +# define INVALID_TIME_CHECK(a) ((a) < 0) +#endif + + int pubkey_letter( int algo ) { @@ -444,12 +452,8 @@ mk_datestr (char *buffer, time_t atime) { struct tm *tp; - /* Note: VMS uses an unsigned time_t thus the compiler yields a - warning here. You may ignore this warning or def out this test - for VMS. The proper way to handle this would be a configure - test to a detect properly implemented unsigned time_t. */ - if ( atime < 0 ) /* 32 bit time_t and after 2038-01-19 */ - strcpy (buffer, "????" "-??" "-??"); /* mark this as invalid */ + if (INVALID_TIME_CHECK (atime)) + strcpy (buffer, "????" "-??" "-??"); /* Mark this as invalid. */ else { tp = gmtime (&atime); sprintf (buffer,"%04d-%02d-%02d", diff --git a/util/ChangeLog b/util/ChangeLog index e5928a32a..767d0bea7 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,8 @@ +2010-10-27 Werner Koch + + * miscutil.c (INVALID_TIME_CHECK): New. + (strtimestamp, isotimestamp, asctimestamp): Use it. + 2010-09-28 Steven M. Schweda (wk) Changes to help the VMS port. See diff --git a/util/miscutil.c b/util/miscutil.c index f74d3e38b..16c2b2b4c 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -31,6 +31,13 @@ #include "util.h" #include "i18n.h" +#ifdef HAVE_UNSIGNED_TIME_T +# define INVALID_TIME_CHECK(a) ((a) == (time_t)(-1)) +#else + /* Error or 32 bit time_t and value after 2038-01-19. */ +# define INVALID_TIME_CHECK(a) ((a) < 0) +#endif + /**************** * I know that the OpenPGP protocol has a Y2106 problem ;-) */ @@ -117,8 +124,8 @@ strtimestamp( u32 stamp ) static char buffer[11+5]; struct tm *tp; time_t atime = stamp; - - if (atime < 0) { + + if (INVALID_TIME_CHECK (atime)) { strcpy (buffer, "????" "-??" "-??"); } else { @@ -140,7 +147,7 @@ isotimestamp (u32 stamp) struct tm *tp; time_t atime = stamp; - if (atime < 0) { + if (INVALID_TIME_CHECK (atime)) { strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??"); } else { @@ -216,10 +223,11 @@ asctimestamp( u32 stamp ) struct tm *tp; time_t atime = stamp; - if (atime < 0) { + if (INVALID_TIME_CHECK (atime)) + { strcpy (buffer, "????" "-??" "-??"); return buffer; - } + } tp = localtime( &atime ); #ifdef HAVE_STRFTIME