From 7b7347575cd627d8f4f4a89b9e4c9551270321ac Mon Sep 17 00:00:00 2001 From: Liviu Chircu Date: Mon, 30 Aug 2021 15:15:40 +0300 Subject: [PATCH] dialplan/drouting: Fix time recurrence check interpretation 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 3056a37407f4cd29dc5e486c12449efe7f4c634e) --- modules/dialplan/dp_repl.c | 4 ++-- modules/drouting/prefix_tree.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/dialplan/dp_repl.c b/modules/dialplan/dp_repl.c index 1a5dc2cca37..6ff94dd03f2 100644 --- a/modules/dialplan/dp_repl.c +++ b/modules/dialplan/dp_repl.c @@ -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; } @@ -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; } diff --git a/modules/drouting/prefix_tree.c b/modules/drouting/prefix_tree.c index 656138609be..acc149445db 100644 --- a/modules/drouting/prefix_tree.c +++ b/modules/drouting/prefix_tree.c @@ -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;