Fix integer overrun
Added casts to oc_clock_time_t for OC_DTLS_INACTIVITY_TIMEOUT when using
larger values (eg. 3600).
Tested-by: IoTivity Jenkins
@@ -186,7 +186,8 @@ oc_tls_inactive(void *data)
if (is_peer_active(peer)) {
oc_clock_time_t time = oc_clock_time();
time -= peer->timestamp;
- if (time < OC_DTLS_INACTIVITY_TIMEOUT * OC_CLOCK_SECOND) {
+ if (time < (oc_clock_time_t)OC_DTLS_INACTIVITY_TIMEOUT *
+ (oc_clock_time_t)OC_CLOCK_SECOND) {
OC_DBG("oc_tls: Resetting DTLS inactivity callback");
return OC_EVENT_CONTINUE;
}
@@ -412,8 +413,8 @@ oc_tls_add_peer(oc_endpoint_t *endpoint, int role)
if (!(endpoint->flags & TCP)) {
mbedtls_ssl_set_timer_cb(&peer->ssl_ctx, &peer->timer, ssl_set_timer,
ssl_get_timer);
- oc_ri_add_timed_event_callback_seconds(peer, oc_tls_inactive,
- OC_DTLS_INACTIVITY_TIMEOUT);
+ oc_ri_add_timed_event_callback_seconds(
+ peer, oc_tls_inactive, (oc_clock_time_t)OC_DTLS_INACTIVITY_TIMEOUT);
}
} else {
OC_WRN("TLS peers exhausted");
