Skip to content

Commit

Permalink
dialplan/drouting: Fix time recurrence check interpretation
Browse files Browse the repository at this point in the history
The tmrec_expr_check() function actually returns 1/-1 on success/failure
and not 1/0, as expected by the calling modules.

Many thanks to Flavio Goncalves for the report!
Fixes #2616

(cherry picked from commit 3056a37)
  • Loading branch information
liviuchircu committed Aug 30, 2021
1 parent f380dc5 commit 7b73475
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/dialplan/dp_repl.c
Expand Up @@ -304,7 +304,7 @@ int translate(struct sip_msg *msg, str input, str * output, dpl_id_p idp, str *
if(rulep->parsed_timerec) {
LM_DBG("Timerec exists for rule checking: %.*s\n", rulep->timerec.len, rulep->timerec.s);
// Doesn't matches time period continue with next rule
if(!tmrec_expr_check(rulep->parsed_timerec)) {
if(tmrec_expr_check(rulep->parsed_timerec) < 0) {
LM_DBG("Time rule doesn't match: skip next!\n");
continue;
}
Expand All @@ -328,7 +328,7 @@ int translate(struct sip_msg *msg, str input, str * output, dpl_id_p idp, str *
if(rrulep->parsed_timerec) {
LM_DBG("Timerec exists for rule checking: %.*s\n", rrulep->timerec.len, rrulep->timerec.s);
// Doesn't matches time period continue with next rule
if(!tmrec_expr_check(rrulep->parsed_timerec)) {
if(tmrec_expr_check(rrulep->parsed_timerec) < 0) {
LM_DBG("Time rule doesn't match: skip next!\n");
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/drouting/prefix_tree.c
Expand Up @@ -104,7 +104,7 @@ internal_check_rt(
j = 0;
while(rtlw!=NULL) {
if ( j++ >= *rgidx) {
if (!rtlw->rtl->time_rec || tmrec_expr_check(rtlw->rtl->time_rec))
if (!rtlw->rtl->time_rec || tmrec_expr_check(rtlw->rtl->time_rec) == 1)
goto ok_exit;
}
rtlw=rtlw->next;
Expand Down

0 comments on commit 7b73475

Please sign in to comment.