Skip to content

Commit

Permalink
fraud_detection: Add coverity tag and cast time_t
Browse files Browse the repository at this point in the history
CID #417467, #417548, #417553, #417570, #417667, #417684,
    #417723, #417807, #417829, #417703, #417490
  • Loading branch information
oanatitoc committed Sep 26, 2024
1 parent d68659c commit f8bb0d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/fraud_detection/fraud_detection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/fraud_detection/frd_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f8bb0d1

Please sign in to comment.