[PATCH] small fix to avoid integer overflow
Robert Millan
rmh at gnu.org
Sat Mar 17 11:36:06 CET 2012
Hi,
Please consider casting the result of get_days() to time_t before
converting it to seconds (rather than afterwards). Otherwise it
becomes affected by Y2K38 bug unnecessarily.
--
Robert Millan
-------------- next part --------------
diff --git a/src/certtool.c b/src/certtool.c
index df23033..0c4ed9a 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -417,7 +417,7 @@ generate_certificate (gnutls_privkey_t * ret_key,
result =
gnutls_x509_crt_set_expiration_time (crt,
- time (NULL) + days * 24 * 60 * 60);
+ time (NULL) + ((time_t) days) * 24 * 60 * 60);
if (result < 0)
error (EXIT_FAILURE, 0, "set_expiration: %s", gnutls_strerror (result));
@@ -933,7 +933,7 @@ update_signed_certificate (common_info_st * cinfo)
days = get_days ();
result =
- gnutls_x509_crt_set_expiration_time (crt, tim + days * 24 * 60 * 60);
+ gnutls_x509_crt_set_expiration_time (crt, tim + ((time_t) days) * 24 * 60 * 60);
if (result < 0)
error (EXIT_FAILURE, 0, "set_expiration: %s", gnutls_strerror (result));
More information about the Gnutls-devel
mailing list