From b734fc080ea70520b2cee0a6369f8fbe3ac89b66 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Sat, 5 Jun 2021 07:55:38 -0400 Subject: [PATCH] TT#14008 fix integer handling (overflow/sign) issues Warned-by: coverity Change-Id: Ia473075046253b2ffcf65344f65469772e6df993 --- daemon/dtmf.c | 4 ++-- lib/codeclib.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/dtmf.c b/daemon/dtmf.c index 7784a5924..28cb633d6 100644 --- a/daemon/dtmf.c +++ b/daemon/dtmf.c @@ -55,7 +55,7 @@ static void dtmf_bencode_and_notify(struct media_packet *mp, bencode_dictionary_add_string(data, "source_ip", sockaddr_print_buf(&mp->fsin.address)); bencode_dictionary_add_integer(data, "timestamp", rtpe_now.tv_sec); bencode_dictionary_add_integer(data, "event", dtmf->event); - bencode_dictionary_add_integer(data, "duration", (ntohs(dtmf->duration) * (1000000 / clockrate)) / 1000); + bencode_dictionary_add_integer(data, "duration", ((long long) ntohs(dtmf->duration) * (1000000LL / clockrate)) / 1000LL); bencode_dictionary_add_integer(data, "volume", dtmf->volume); bencode_collapse_str(notify, &encoded_data); @@ -357,7 +357,7 @@ const char *dtmf_inject(struct call_media *media, int code, int volume, int dura ssrc_in->parent->h.ssrc); // synthesise start and stop events - uint64_t num_samples = duration * ch->dest_pt.clock_rate / 1000; + uint64_t num_samples = (uint64_t) duration * ch->dest_pt.clock_rate / 1000; uint64_t start_pts = codec_encoder_pts(csh); uint64_t last_end_pts = codec_last_dtmf_event(csh); if (last_end_pts) { diff --git a/lib/codeclib.c b/lib/codeclib.c index 0a69f3071..f13f5f4a1 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -2020,7 +2020,7 @@ static int amr_decoder_input(decoder_t *dec, const str *data, GQueue *out) { if (!dec->u.avc.u.amr.last_cmr.tv_sec) // start tracking now dec->u.avc.u.amr.last_cmr = rtpe_now; else if (timeval_diff(&rtpe_now, &dec->u.avc.u.amr.last_cmr) - >= dec->codec_options.amr.mode_change_interval * 1000) { + >= (long long) dec->codec_options.amr.mode_change_interval * 1000) { // switch up if we can decoder_event(dec, CE_AMR_CMR_RECV, GUINT_TO_POINTER(0xffff)); dec->u.avc.u.amr.last_cmr = rtpe_now;