aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2023-10-14 15:23:42 +0000
committerWerner Koch <[email protected]>2023-10-14 15:27:38 +0000
commit5eaf2e926637163621bc0a43b598a19bddefa247 (patch)
treeafe01e4b3250db5f69344221fe15aab6e2bc7629
parentcommon: New function scan_secondsstr. (diff)
downloadgnupg-5eaf2e926637163621bc0a43b598a19bddefa247.tar.gz
gnupg-5eaf2e926637163621bc0a43b598a19bddefa247.zip
gpg: Allow to specify seconds since Epoch beyond 2038.
* g10/keygen.c (parse_expire_string_with_ct): Use new function scan_secondsstr. (parse_creation_string): Ditto. -- Noet that we cap the seconds at the year 2106. GnuPG-bug-id: 6736
-rw-r--r--g10/keygen.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/g10/keygen.c b/g10/keygen.c
index d2788fb01..db4c49bfb 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -2691,14 +2691,21 @@ parse_expire_string( const char *string )
|| !strcmp (string, "never") || !strcmp (string, "-"))
seconds = 0;
else if (!strncmp (string, "seconds=", 8))
- seconds = atoi (string+8);
+ seconds = scan_secondsstr (string+8);
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 ((mult = check_valid_days (string)))
- seconds = atoi (string) * 86400L * mult;
+ {
+ uint64_t tmp64;
+ tmp64 = scan_secondsstr (string) * 86400L * mult;
+ if (tmp64 >= (u32)(-1))
+ seconds = (u32)(-1) - 1; /* cap value. */
+ else
+ seconds = (u32)tmp64;
+ }
else
seconds = (u32)(-1);
@@ -2715,7 +2722,7 @@ parse_creation_string (const char *string)
if (!*string)
seconds = 0;
else if ( !strncmp (string, "seconds=", 8) )
- seconds = atoi (string+8);
+ seconds = scan_secondsstr (string+8);
else if ( !(seconds = scan_isodatestr (string)))
{
time_t tmp = isotime2epoch (string);