From f8bb0d132a6594597a7ae41ee878e8b66be16919 Mon Sep 17 00:00:00 2001 From: Alexandra Titoc Date: Thu, 26 Sep 2024 11:59:58 +0300 Subject: [PATCH] fraud_detection: Add coverity tag and cast time_t CID #417467, #417548, #417553, #417570, #417667, #417684, #417723, #417807, #417829, #417703, #417490 --- modules/fraud_detection/fraud_detection.c | 10 +++++++++- modules/fraud_detection/frd_events.c | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/fraud_detection/fraud_detection.c b/modules/fraud_detection/fraud_detection.c index 4a64cef5be8..3c12e1370fe 100644 --- a/modules/fraud_detection/fraud_detection.c +++ b/modules/fraud_detection/fraud_detection.c @@ -361,7 +361,7 @@ static int check_fraud(struct sip_msg *msg, str *user, str *number, int *pid) /* more than t0 + WINDOW_SIZE but less than 2 * WINDOW_SIZE * we can consider calls from t0 + (now - WINDOW_SIZE) * all cals from t0 to t0 + (now - WINDOW_SIZE) shall be invalidated */ - unsigned int old_matched_time = se->stats.last_matched_time; + unsigned int old_matched_time = (unsigned int)(unsigned long)se->stats.last_matched_time; se->stats.last_matched_time = nowt - FRD_SECS_PER_WINDOW + 1; @@ -394,13 +394,21 @@ static int check_fraud(struct sip_msg *msg, str *user, str *number, int *pid) rc = rc_ ## type ## _thr;\ } + /* coverity[overrun-buffer-val: FALSE] */ if CHECK_AND_RAISE(cpm, critical) + /* coverity[overrun-buffer-val: FALSE] */ else if CHECK_AND_RAISE(total_calls, critical) + /* coverity[overrun-buffer-val: FALSE] */ else if CHECK_AND_RAISE(concurrent_calls, critical) + /* coverity[overrun-buffer-val: FALSE] */ else if CHECK_AND_RAISE(seq_calls, critical) + /* coverity[overrun-buffer-val: FALSE] */ else if CHECK_AND_RAISE(cpm, warning) + /* coverity[overrun-buffer-val: FALSE] */ else if CHECK_AND_RAISE(total_calls, warning) + /* coverity[overrun-buffer-val: FALSE] */ else if CHECK_AND_RAISE(concurrent_calls, warning) + /* coverity[overrun-buffer-val: FALSE] */ else if CHECK_AND_RAISE(seq_calls, warning); #undef CHECK_AND_RAISE diff --git a/modules/fraud_detection/frd_events.c b/modules/fraud_detection/frd_events.c index 4c6a2e086d9..6a623ff230b 100644 --- a/modules/fraud_detection/frd_events.c +++ b/modules/fraud_detection/frd_events.c @@ -164,12 +164,16 @@ void dialog_terminate_CB(struct dlg_cell *dlg, int type, /* avoid generating alerts on CANCEL/487 calls, but decrement the CC */ if (!(type & DLGCB_FAILED) && frdparam->calldur_crit && duration >= frdparam->calldur_crit) + + /* coverity[overrun-buffer-val: FALSE] */ raise_critical_event(&call_dur_name, &duration, &frdparam->calldur_crit, &frdparam->user, &frdparam->number, &frdparam->ruleid, &frdparam->pid); else if (!(type & DLGCB_FAILED) && frdparam->calldur_warn && duration >= frdparam->calldur_warn) + + /* coverity[overrun-buffer-val: FALSE] */ raise_warning_event(&call_dur_name, &duration, &frdparam->calldur_warn, &frdparam->user, &frdparam->number, &frdparam->ruleid, &frdparam->pid);