diff options
author | Werner Koch <[email protected]> | 2023-10-26 10:01:44 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2023-10-26 10:01:44 +0000 |
commit | 5da8fe1c402d59c2354601d77704ecdc1e777837 (patch) | |
tree | e8bf0d0ff84d89aa8512b5bf91b2a9d2ef9b9097 | |
parent | common: New functions timegm_u64, isotime2epoch_u64. (diff) | |
download | gnupg-5da8fe1c402d59c2354601d77704ecdc1e777837.tar.gz gnupg-5da8fe1c402d59c2354601d77704ecdc1e777837.zip |
gpg: Allow expiration time after 2013-01-19 on 32 bit Windows.
* g10/keygen.c (parse_expire_string): Use isotime2epoch_u64.
(parse_creation_string): Ditto.
--
GnuPG-bug-id: 6736
-rw-r--r-- | g10/keygen.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/g10/keygen.c b/g10/keygen.c index db4c49bfb..95d71baa4 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -2679,13 +2679,14 @@ ask_curve (int *algo, int *subkey_algo, const char *current) * similar. */ u32 -parse_expire_string( const char *string ) +parse_expire_string (const char *string) { int mult; u32 seconds; u32 abs_date = 0; u32 curtime = make_timestamp (); - time_t tt; + uint64_t tt; + uint64_t tmp64; if (!string || !*string || !strcmp (string, "none") || !strcmp (string, "never") || !strcmp (string, "-")) @@ -2695,11 +2696,16 @@ parse_expire_string( const char *string ) else if ((abs_date = scan_isodatestr(string)) && (abs_date+86400/2) > curtime) seconds = (abs_date+86400/2) - curtime; - else if ((tt = isotime2epoch (string)) != (time_t)(-1)) - seconds = (u32)tt - curtime; + else if ((tt = isotime2epoch_u64 (string)) != (uint64_t)(-1)) + { + tmp64 = tt - curtime; + if (tmp64 >= (u32)(-1)) + seconds = (u32)(-1) - 1; /* cap value. */ + else + seconds = (u32)tmp64; + } else if ((mult = check_valid_days (string))) { - uint64_t tmp64; tmp64 = scan_secondsstr (string) * 86400L * mult; if (tmp64 >= (u32)(-1)) seconds = (u32)(-1) - 1; /* cap value. */ @@ -2725,8 +2731,13 @@ parse_creation_string (const char *string) seconds = scan_secondsstr (string+8); else if ( !(seconds = scan_isodatestr (string))) { - time_t tmp = isotime2epoch (string); - seconds = (tmp == (time_t)(-1))? 0 : tmp; + uint64_t tmp = isotime2epoch_u64 (string); + if (tmp == (uint64_t)(-1)) + seconds = 0; + else if (tmp > (u32)(-1)) + seconds = 0; + else + seconds = tmp; } return seconds; } |