diff options
author | Werner Koch <[email protected]> | 2010-10-27 11:26:53 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2010-10-27 11:26:53 +0000 |
commit | 2e82b095cd2ebd3ecc1635bb5cbe65eb99de7ae7 (patch) | |
tree | b87aea270583496526aff9f82b927f6298662451 /g10 | |
parent | Honor TMPDIR. (diff) | |
download | gnupg-2e82b095cd2ebd3ecc1635bb5cbe65eb99de7ae7.tar.gz gnupg-2e82b095cd2ebd3ecc1635bb5cbe65eb99de7ae7.zip |
Better support unsigned time_t
Diffstat (limited to 'g10')
-rw-r--r-- | g10/ChangeLog | 7 | ||||
-rw-r--r-- | g10/keygen.c | 2 | ||||
-rw-r--r-- | g10/keyid.c | 15 |
3 files changed, 17 insertions, 7 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index 65f9117c1..2da7b3c4f 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,10 @@ +2010-10-27 Werner Koch <[email protected]> + + * keygen.c (ask_expire_interval): Do not print the y2038 if we + have an unsigned time_t. + * keyid.c (IS_INVALID_TIME_T): New. + (mk_datestr): Use it to detect the y2038 problem. + 2010-10-26 Werner Koch <[email protected]> * keyedit.c (change_passphrase): Handle the passwd_nonce. diff --git a/g10/keygen.c b/g10/keygen.c index 03d53ce0b..e718a83e8 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -1854,7 +1854,7 @@ ask_expire_interval(int object,const char *def_expire) ? _("Key expires at %s\n") : _("Signature expires at %s\n"), asctimestamp((ulong)(curtime + interval) ) ); -#if SIZEOF_TIME_T <= 4 +#if SIZEOF_TIME_T <= 4 && !defined (HAVE_UNSIGNED_TIME_T) if ( (time_t)((ulong)(curtime+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 128428720..62ce03685 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -37,6 +37,13 @@ #define KEYID_STR_SIZE 19 +#ifdef HAVE_UNSIGNED_TIME_T +# define IS_INVALID_TIME_T(a) ((a) == (time_t)(-1)) +#else + /* Error or 32 bit time_t and value after 2038-01-19. */ +# define IS_INVALID_TIME_T(a) ((a) < 0) +#endif + /* Return a letter describing the public key algorithms. */ int @@ -446,12 +453,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 (IS_INVALID_TIME_T (atime)) + strcpy (buffer, "????" "-??" "-??"); /* Mark this as invalid. */ else { tp = gmtime (&atime); |