diff options
author | Werner Koch <wk@gnupg.org> | 2008-08-11 10:08:08 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2008-08-11 10:08:08 +0200 |
commit | ac5c3fab300b18fa7013483e243e1becf699b69f (patch) | |
tree | a402aff3fa64f5b8494b49f3bace7e1180ca33df /g10 | |
parent | Fix APDU buffer problem under MAC OS. (diff) | |
download | gnupg2-ac5c3fab300b18fa7013483e243e1becf699b69f.tar.xz gnupg2-ac5c3fab300b18fa7013483e243e1becf699b69f.zip |
Cehck for expire date overflows.
Diffstat (limited to 'g10')
-rw-r--r-- | g10/keygen.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/g10/keygen.c b/g10/keygen.c index 4e8dd50b4..a056e5320 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -1789,21 +1789,23 @@ ask_keysize( int algo ) u32 parse_expire_string( const char *string ) { - int mult; - u32 seconds,abs_date=0,curtime = make_timestamp(); - - if( !*string ) - seconds = 0; - else if ( !strncmp (string, "seconds=", 8) ) - seconds = atoi (string+8); - else if( (abs_date = scan_isodatestr(string)) && abs_date > curtime ) - seconds = abs_date - curtime; - else if( (mult=check_valid_days(string)) ) - seconds = atoi(string) * 86400L * mult; - else - seconds=(u32)-1; - - return seconds; + int mult; + u32 seconds; + u32 abs_date = 0; + u32 curtime = make_timestamp (); + + if (!*string) + seconds = 0; + else if (!strncmp (string, "seconds=", 8)) + seconds = atoi (string+8); + else if ((abs_date = scan_isodatestr(string)) && abs_date > curtime) + seconds = abs_date - curtime; + else if ((mult = check_valid_days (string))) + seconds = atoi (string) * 86400L * mult; + else + seconds = (u32)(-1); + + return seconds; } /* Parsean Creation-Date string which is either "1986-04-26" or @@ -1916,7 +1918,13 @@ ask_expire_interval(int object,const char *def_expire) tty_printf (_("Your system can't display dates beyond 2038.\n" "However, it will be correctly handled up to" " 2106.\n")); + else #endif /*SIZEOF_TIME_T*/ + if ( (time_t)((unsigned long)(curtime+interval)) < curtime ) + { + tty_printf (_("invalid value\n")); + continue; + } } if( cpr_enabled() || cpr_get_answer_is_yes("keygen.valid.okay", |