--- channels/chan_sip.c (Asterisk 13.5.0) +++ channels/chan_sip.c (working copy) @@ -3952,14 +3952,13 @@ sip_methods[pkt->method].text, pkt->method); } - if (!pkt->timer_a) { - pkt->timer_a = 2 ; - } else { - pkt->timer_a = 2 * pkt->timer_a; + + siptimer_a = pkt->timer_t1 < pkt->retrans; /* Double each time */ + if (siptimer_a < pkt->timer_t1 * 2) { /* signed int overflow? */ + siptimer_a = INT_MAX; /* Workaround any overflow, like negative value or 0 */ } /* For non-invites, a maximum of 4 secs */ - siptimer_a = pkt->timer_t1 * pkt->timer_a; /* Double each time */ if (pkt->method != SIP_INVITE && siptimer_a > 4000) { siptimer_a = 4000; } --- channels/sip/include/sip.h (Asterisk 13.5.0) +++ channels/sip/include/sip.h (working copy) @@ -1223,7 +1223,7 @@ int response_code; /*!< If this is a response, the response code */ struct sip_pvt *owner; /*!< Owner AST call */ int retransid; /*!< Retransmission ID */ - int timer_a; /*!< SIP timer A, retransmission timer */ + int timer_a; /*!< not used anymore, re-using retrans now */ int timer_t1; /*!< SIP Timer T1, estimated RTT or 500 ms */ struct timeval time_sent; /*!< When pkt was sent */ int64_t retrans_stop_time; /*!< Time in ms after 'now' that retransmission must stop */ --- main/sched.c (Asterisk 13.5.0) +++ main/sched.c (working copy) @@ -357,6 +357,10 @@ { struct timeval now = ast_tvnow(); + if (when < 0) { + ast_log(LOG_WARNING, "negative time interval %d (interpreted as %u ms) please report this to the Asterisk team!\n", when, when); + } + /*ast_debug(1, "TV -> %lu,%lu\n", tv->tv_sec, tv->tv_usec);*/ if (ast_tvzero(*t)) /* not supplied, default to now */ *t = now;