intliang created an issue (kamailio/kamailio#4214)
### Description
The **<bymonth>** comparison logic in **tmrec_match()** fails to properly
evaluate equivalence conditions, as shown below:
```
int check_byxxx(tmrec_t *_trp, ac_tm_t *_atp)
{
...
if(_trp->bymonth) {
for(i = 0; i < _trp->bymonth->nr; i++) {
if(_atp->t.tm_mon
== (_trp->bymonth->xxx[i] *
_trp->bymonth->req[i] + 12)
% 12)
break;
}
...
```
### Troubleshooting
#### Reproduction
Rule string: "20250403T100000|PT14H|weekly|20250425T000000|2|-1WE, -2WE|16|||4"
Date time: 20250416T190000
Expected output: MATCH
Actual output: NOT MATCH
<!--
If the issue can be reproduced, describe how it can be done.
-->
#### Debugging Data
<!--
If you got a core dump, use gdb to extract troubleshooting data - full
backtrace,
local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile
bt full
info locals
list
If you are familiar with gdb, feel free to attach more of what you consider to
be relevant.
-->
```
((lldb) p _trp->bymonth->xxx[0]
(int) 4
(lldb) p _trp->bymonth->req[0]
(int) 1
(lldb) p _atp->t.tm_mon
(int) 3
(lldb) p _trp->bymonth->nr
(int) 1
```
#### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by
Kamailio, add them next, or attach to issue, or provide a link to download them
(e.g., to a pastebin site).
-->
```
(paste your log messages here)
```
#### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with
ngrep or save in a pcap file, then add them next, or attach to issue, or
provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your sip traffic here)
```
### Possible Solutions
The **tm_mon** field in the tm struct uses a 0-11 range (January=0), while the
**<bymonth>** parameter follows a 1-12 convention (January=1) as documented in
the tmrec module's README. Therefore, we should first decrement the value of
**_trp->bymonth->xxx[i]** by 1 for proper conversion.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 6.1.0-dev0 (x86_64/Darwin) 9f24f1-dirty
flags: , EXTRA_DEBUGUSE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE,
USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC,
DBG_SR_MEMORY, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER,
USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_SEND_BUFFER_SIZE
262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, select, kqueue.
id: 9f24f1 dirty
compiled on 11:59:55 Apr 16 2025 with AppleClang 17.0.0.17000013
```
* **Operating System**:
```
Darwin yintiliangdeMacBook-Pro19.local 24.2.0 Darwin Kernel Version 24.2.0: Fri
Dec 6 18:41:43 PST 2024; root:xnu-11215.61.5~2/RELEASE_X86_64 x86_64
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4214
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4...@github.com>
_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the
sender!