mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
common: Guarantee that gnupg_get_time does not return an error.
* common/gettime.c (gnupg_get_time): Abor if time() failed. (gnupg_get_isotime): Remove now useless check. (make_timestamp): Remove check becuase we already checked this modulo the faked time thing. -- In reality a call foo = time (NULL) can never fail because the only defined error is EFAULT, but we don't provide a buffer. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
460568d341
commit
5eb2682686
@ -60,6 +60,9 @@ time_t
|
|||||||
gnupg_get_time ()
|
gnupg_get_time ()
|
||||||
{
|
{
|
||||||
time_t current = time (NULL);
|
time_t current = time (NULL);
|
||||||
|
if (current == (time_t)(-1))
|
||||||
|
log_fatal ("time() failed\n");
|
||||||
|
|
||||||
if (timemode == NORMAL)
|
if (timemode == NORMAL)
|
||||||
return current;
|
return current;
|
||||||
else if (timemode == FROZEN)
|
else if (timemode == FROZEN)
|
||||||
@ -99,11 +102,6 @@ void
|
|||||||
gnupg_get_isotime (gnupg_isotime_t timebuf)
|
gnupg_get_isotime (gnupg_isotime_t timebuf)
|
||||||
{
|
{
|
||||||
time_t atime = gnupg_get_time ();
|
time_t atime = gnupg_get_time ();
|
||||||
|
|
||||||
if (atime == (time_t)(-1))
|
|
||||||
*timebuf = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct tm *tp;
|
struct tm *tp;
|
||||||
struct tm tmbuf;
|
struct tm tmbuf;
|
||||||
|
|
||||||
@ -114,7 +112,6 @@ gnupg_get_isotime (gnupg_isotime_t timebuf)
|
|||||||
snprintf (timebuf, 16, "%04d%02d%02dT%02d%02d%02d",
|
snprintf (timebuf, 16, "%04d%02d%02dT%02d%02d%02d",
|
||||||
1900 + tp->tm_year, tp->tm_mon+1, tp->tm_mday,
|
1900 + tp->tm_year, tp->tm_mon+1, tp->tm_mday,
|
||||||
tp->tm_hour, tp->tm_min, tp->tm_sec);
|
tp->tm_hour, tp->tm_min, tp->tm_sec);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -164,9 +161,6 @@ u32
|
|||||||
make_timestamp (void)
|
make_timestamp (void)
|
||||||
{
|
{
|
||||||
time_t t = gnupg_get_time ();
|
time_t t = gnupg_get_time ();
|
||||||
|
|
||||||
if (t == (time_t)-1)
|
|
||||||
log_fatal ("gnupg_get_time() failed\n");
|
|
||||||
return (u32)t;
|
return (u32)t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user