Skip to content

Commit

Permalink
Fix warnings with unsigned time_t
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #19843)
  • Loading branch information
jwt27 authored and paulidale committed Dec 8, 2022
1 parent 2a21003 commit afec90d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ssl/ssl_sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ __owur static int timeoutcmp(SSL_SESSION *a, SSL_SESSION *b)
*/
void ssl_session_calculate_timeout(SSL_SESSION *ss)
{
#ifndef __DJGPP__ /* time_t is unsigned on djgpp */
/* Force positive timeout */
if (ss->timeout < 0)
ss->timeout = 0;
#endif
ss->calc_timeout = ss->time + ss->timeout;
/*
* |timeout| is always zero or positive, so the check for
Expand All @@ -70,7 +72,7 @@ void ssl_session_calculate_timeout(SSL_SESSION *ss)
ss->timeout_ovf = ss->time > 0 && ss->calc_timeout < ss->time;
/*
* N.B. Realistic overflow can only occur in our lifetimes on a
* 32-bit machine in January 2038.
* 32-bit machine with signed time_t, in January 2038.
* However, There are no controls to limit the |timeout|
* value, except to keep it positive.
*/
Expand Down
2 changes: 1 addition & 1 deletion ssl/statem/extensions_srvr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
* rounding errors.
*/
if (id == 0
&& sess->timeout >= (long)agesec
&& sess->timeout >= (time_t)agesec
&& agems / (uint32_t)1000 == agesec
&& ticket_age <= agems + 1000
&& ticket_age + TICKET_AGE_ALLOWANCE >= agems + 1000) {
Expand Down

0 comments on commit afec90d

Please sign in to comment.