### Description
On creating dispatcher with `kamctl` in the case of `db_text` it fails
### Troubleshooting
#### Reproduction
Point `kamctlrc` to DB_TEXT.
Run `kamctl dispatcher add 1 sip:asterisk_2:5060 1 3`
Run 'kamctl dispatcher add 1 sip:asterisk_2:5060 1 3 'prefix=123' 'test1''
Run 'kamctl dispatcher show'
Run 'kamctl dispatcher reload'
#### Debugging Data
```
# kamctl dispatcher add 1 sip:asterisk_2:5060 1 3
attrs cannot be empty or null
-e \E[37;31mERROR: dispatcher - SQL Error
```
```
# kamctl dispatcher add 1 sip:asterisk_2:5060 1 3 'prefix=123' 'test1'
Traceback (most recent call last):
File "/usr/lib/x86_64-linux-gnu/kamailio//kamctl/dbtextdb/dbtextdb.py", line 1243, in <module>
main(sys.argv)
File "/usr/lib/x86_64-linux-gnu/kamailio//kamctl/dbtextdb/dbtextdb.py", line 1230, in main
dataset = conn.Execute(' '.join(argv[1:]))
File "/usr/lib/x86_64-linux-gnu/kamailio//kamctl/dbtextdb/dbtextdb.py", line 423, in Execute
self.WriteTempTable()
File "/usr/lib/x86_64-linux-gnu/kamailio//kamctl/dbtextdb/dbtextdb.py", line 1138, in WriteTempTable
self.temp_file.write(header.strip() + '\n')
File "/usr/lib/python3.7/tempfile.py", line 620, in func_wrapper
return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'
-e \E[37;31mERROR: dispatcher - SQL Error
```
dump is showing active dispatchers, show - is not.
```
# kamctl dispatcher dump
{
"jsonrpc": "2.0",
"result": {
"NRSETS": 1,
"RECORDS": [{
"SET": {
"ID": 1,
"TARGETS": [{
"DEST": {
"URI": "sip:asterisk_2:5060",
"FLAGS": "AP",
"PRIORITY": 0
}
}]
}
}]
},
"id": 124
}
root@e529c8cb4f62:/# kamctl dispatcher show
-e dispatcher gateways
```
No result on reload
```
# kamctl dispatcher reload
{
"jsonrpc": "2.0",
"result": {
},
"id": 160
}
```
### Possible Solutions
I've tried to add data to the table manually, but here I got another issue.
But on Kamailio load, the only first dispatcher is processed. Will add another issue on this.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
/# kamailio -v
version: kamailio 5.4.1 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 8.3.0
```
* **Operating System**:
Debian 10/Docker
```
# uname -a
Linux 9b7efa852274 5.3.18-lp152.36-default #1 SMP Tue Aug 18 17:09:44 UTC 2020 (885251f) x86_64 GNU/Linux
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2464
### Description
I am creating a module that uses a 3rd party library(wolfSSL), that depending on build flags,
requires alignment of memory blocks to be the same as `malloc`, i.e., 16 bytes on gcc/AMD64.
It seems that `shm_malloc` returns memory aligned to 8 bytes.
Since system malloc always returns 16-byte aligned memory, it might be good to match that
behaviour in `shm_malloc` in case future kamailio modules use libraries that expect this.
### Expected behavior
`shm_malloc` returns memory aligned on `__alignof__(_max_align_t) == 16`
#### Actual observed behavior
`shm_malloc` returns blocks aligned on 8-bytes
#### Debugging Data
When allocating `*SSL_CTX` and `*SSL ` structs by tls module they occassionally will
have 8 byte (and not necessarily 16-byte) alignments. OpenSSL does not require 16-byte alignments
but wolfSSL requires 16-byte alignments.
### Possible Solutions
* The custom memory allocators in WIP `tls_wolfssl/` could try to wrap around `shm_malloc`.
* have a static build of wolfSSL that does not require 16-byte alignment
### Additional Information
The default `./configure` build of wolfSSL has structs that require 16-byte alignment.
wolfSSL library has a configure flag `--enable-aligndata=no` that relaxes this requirement.
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3157
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3157(a)github.com>
### Description
While upgrading to kamailio version 5.5.2 I noticed that the sip reason is not always filled in correctly. In our current setup with kamailio version 4.4 the acc module writes the INVITE, ACK end BYE messages to a postgres database. Also the missed calls are logged. With version 5.5.2 but also with version 5.5.3 the sip reason seems to contain a random 2 digits.
It gets even worse when a call is missed and kamailio generates a 408 timeout. Then a random string of 15 characters is written to the database. Sometimes this results in a fatal error because the postgres driver can't escape the string.
### Troubleshooting
The relevant part in de code is in the function env_set_code_status in file acc_logic.c
if (reply==FAKED_REPLY || reply==NULL) {
/* code */
acc_env.code_s.s =
int2bstr((unsigned long)code, code_buf, &acc_env.code_s.len);
/* reason */
if (acc_env.reason.len == 0) { /* already extracted in case of locally generated replies */
acc_env.reason.s = error_text(code);
acc_env.reason.len = strlen(acc_env.reason.s);
}
The sip reason is only filled in when the len is 0, but once the length is set it looks like it's not being reset to 0 again somewhere.
I can fix the problem by removing the if statement, but that is probably not the intention of the programmer.
#### Reproduction
The wrong reason in the ACK can probably be reproduces with any call, but in my test setup an Asterisk system answers the call.
After the "OK" an ACK is received which is seen as a FAKED_REPLY. The reason.len however is still 2 and the reason is not set.
The new function "env_set_reason" is not being called in this case.
The issue with the 408 can be reproduced by calling an endpoint and let kamailio timeout. This has to be done twice to reproduce the error. This time kamailio wants to write the missed INVITE to the database with a random string of 15 characters for the sip reason.
To me it looks like the length of 15 comes from the length of the "Request Timeout" string but the pointer reason.s point to a memory part of a previous transaction which is already gone ?
#### Debugging Data
#### Log Messages
#### SIP Traffic
### Possible Solutions
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.5.2 (x86_64/linux) 55e232
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, 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_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 55e232
compiled on 15:45:52 Dec 9 2021 with gcc 8.3.0
```
* **Operating System**:
```
Linux 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2981
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/2981(a)github.com>
- Use heap memory for the reason code instead of the stack memory.
- See issue #2981
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [x] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [x] Related to issue #2981 (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3137
-- Commit Summary --
* acc: Fix reason code for locally generated replies.
-- File Changes --
M src/modules/acc/acc_logic.c (17)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3137.patchhttps://github.com/kamailio/kamailio/pull/3137.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3137
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3137(a)github.com>