summaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2023-10-26 12:01:44 +0200
committerWerner Koch <wk@gnupg.org>2023-10-26 12:45:50 +0200
commita4fe307b5535ed350fff63941aaa0b19ee2e683a (patch)
treeed619ef5ad09c3b354fccf451554e7818848ac10 /g10
parentcommon: New functions timegm_u64, isotime2epoch_u64. (diff)
downloadgnupg2-a4fe307b5535ed350fff63941aaa0b19ee2e683a.tar.xz
gnupg2-a4fe307b5535ed350fff63941aaa0b19ee2e683a.zip
gpg: Allow expiration time after 2038-01-19 on 32 bit Windows.
* g10/keygen.c (parse_expire_string_with_ct): Use isotime2epoch_u64. (parse_creation_string): Ditto. -- GnuPG-bug-id: 6736
Diffstat (limited to 'g10')
-rw-r--r--g10/keygen.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/g10/keygen.c b/g10/keygen.c
index 06fc39aa1..87940722d 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -2748,6 +2748,7 @@ parse_expire_string_with_ct (const char *string, u32 creation_time)
u32 seconds;
u32 abs_date = 0;
time_t tt;
+ uint64_t tmp64;
u32 curtime;
if (creation_time == (u32)-1)
@@ -2763,11 +2764,16 @@ parse_expire_string_with_ct (const char *string, u32 creation_time)
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. */
@@ -2800,8 +2806,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;
}