1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-09-21 15:01:41 +02:00

Detect unsigned time_t and adjust y2038 detection.

This commit is contained in:
Werner Koch 2010-10-27 10:59:11 +00:00
parent f7ab9d61bf
commit a6b47500ac
9 changed files with 71 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2010-10-27 Werner Koch <wk@g10code.com>
* acinclude.m4 (GNUPG_TIME_T_UNSIGNED): New.
* configure.ac: Call AC_HEADER_TIME and GNUPG_TIME_T_UNSIGNED.
2010-10-18 Werner Koch <wk@g10code.com> 2010-10-18 Werner Koch <wk@g10code.com>
Release 1.4.11. Release 1.4.11.

1
THANKS
View File

@ -93,6 +93,7 @@ Jan Krueger max@physics.otago.ac.nz
Jan Niehusmann jan@gondor.com Jan Niehusmann jan@gondor.com
Janusz A. Urbanowicz alex@bofh.torun.pl Janusz A. Urbanowicz alex@bofh.torun.pl
James Troup james@nocrew.org James Troup james@nocrew.org
Jason Woodward jason dot woodward at timesys dot com
Jean-loup Gailly gzip@prep.ai.mit.edu Jean-loup Gailly gzip@prep.ai.mit.edu
Jeff Long long@kestrel.cc.ukans.edu Jeff Long long@kestrel.cc.ukans.edu
Jeffery Von Ronne jronne@ics.uci.edu Jeffery Von Ronne jronne@ics.uci.edu

View File

@ -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 <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# 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 GNUPG_CHECK_GNUMAKE
dnl dnl
AC_DEFUN([GNUPG_CHECK_GNUMAKE], AC_DEFUN([GNUPG_CHECK_GNUMAKE],

View File

@ -956,6 +956,7 @@ AC_CHECK_SIZEOF(unsigned short)
AC_CHECK_SIZEOF(unsigned int) AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long) AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned long long) AC_CHECK_SIZEOF(unsigned long long)
AC_HEADER_TIME
AC_CHECK_SIZEOF(time_t,,[[ AC_CHECK_SIZEOF(time_t,,[[
#include <stdio.h> #include <stdio.h>
#if TIME_WITH_SYS_TIME #if TIME_WITH_SYS_TIME
@ -969,6 +970,7 @@ AC_CHECK_SIZEOF(time_t,,[[
# endif # endif
#endif #endif
]]) ]])
GNUPG_TIME_T_UNSIGNED
# Ensure that we have UINT64_C before we bother to check for uint64_t # Ensure that we have UINT64_C before we bother to check for uint64_t
AC_CHECK_HEADERS([inttypes.h]) AC_CHECK_HEADERS([inttypes.h])

View File

@ -1,3 +1,10 @@
2010-10-27 Werner Koch <wk@g10code.com>
* 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 <wk@g10code.com> 2010-10-20 Werner Koch <wk@g10code.com>
* encr-data.c (decode_filter): Cast -1 to size_t. Reported by * encr-data.c (decode_filter): Cast -1 to size_t. Reported by

View File

@ -1789,7 +1789,7 @@ ask_expire_interval(u32 timestamp,int object,const char *def_expire)
? _("Key expires at %s\n") ? _("Key expires at %s\n")
: _("Signature expires at %s\n"), : _("Signature expires at %s\n"),
asctimestamp((ulong)(timestamp + interval) ) ); 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 ) if ((time_t)((ulong)(timestamp+interval)) < 0 )
tty_printf (_("Your system can't display dates beyond 2038.\n" tty_printf (_("Your system can't display dates beyond 2038.\n"
"However, it will be correctly handled up to" "However, it will be correctly handled up to"

View File

@ -33,6 +33,14 @@
#include "keydb.h" #include "keydb.h"
#include "i18n.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 int
pubkey_letter( int algo ) pubkey_letter( int algo )
{ {
@ -444,12 +452,8 @@ mk_datestr (char *buffer, time_t atime)
{ {
struct tm *tp; struct tm *tp;
/* Note: VMS uses an unsigned time_t thus the compiler yields a if (INVALID_TIME_CHECK (atime))
warning here. You may ignore this warning or def out this test strcpy (buffer, "????" "-??" "-??"); /* Mark this as invalid. */
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 */
else { else {
tp = gmtime (&atime); tp = gmtime (&atime);
sprintf (buffer,"%04d-%02d-%02d", sprintf (buffer,"%04d-%02d-%02d",

View File

@ -1,3 +1,8 @@
2010-10-27 Werner Koch <wk@g10code.com>
* miscutil.c (INVALID_TIME_CHECK): New.
(strtimestamp, isotimestamp, asctimestamp): Use it.
2010-09-28 Steven M. Schweda <sms@antinode.info> (wk) 2010-09-28 Steven M. Schweda <sms@antinode.info> (wk)
Changes to help the VMS port. See Changes to help the VMS port. See

View File

@ -31,6 +31,13 @@
#include "util.h" #include "util.h"
#include "i18n.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 ;-) * I know that the OpenPGP protocol has a Y2106 problem ;-)
*/ */
@ -118,7 +125,7 @@ strtimestamp( u32 stamp )
struct tm *tp; struct tm *tp;
time_t atime = stamp; time_t atime = stamp;
if (atime < 0) { if (INVALID_TIME_CHECK (atime)) {
strcpy (buffer, "????" "-??" "-??"); strcpy (buffer, "????" "-??" "-??");
} }
else { else {
@ -140,7 +147,7 @@ isotimestamp (u32 stamp)
struct tm *tp; struct tm *tp;
time_t atime = stamp; time_t atime = stamp;
if (atime < 0) { if (INVALID_TIME_CHECK (atime)) {
strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??"); strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??");
} }
else { else {
@ -216,7 +223,8 @@ asctimestamp( u32 stamp )
struct tm *tp; struct tm *tp;
time_t atime = stamp; time_t atime = stamp;
if (atime < 0) { if (INVALID_TIME_CHECK (atime))
{
strcpy (buffer, "????" "-??" "-??"); strcpy (buffer, "????" "-??" "-??");
return buffer; return buffer;
} }