Description

Providing Kamailio with a domain name longer than 72 chars causes Kamailio to crash with an error in fix_sock_str. Looking at the code it appears that the fix_sock_str function only assumes it is being passed IP addresses so the buffer length is configured for the length of an IPv6 address represented as a string.

It appears to include the portion of the string representing the port as can be seen in the two example config lines below.

Reproduction

The problem can be reproduced by adding the following line to the kamailio.cfg and running kamailio with the -c config check option.

listen=tcp:eth0:5060 advertise "example.example.example.example.example.example.example.example.exa":50
listen=tcp:eth0:5061 advertise "example.example.example.example.example.example.example.example.e":5060

Debugging Data

N/A

Log Messages

 0(100) ERROR: <core> [core/socket_info.c:376]: socketinfo2str(): Destionation buffer too short
 0(100) BUG: <core> [core/socket_info.c:443]: fix_sock_str(): fix_sock_str: Error in socket to str
 0(100) ERROR: <core> [core/socket_info.c:1841]: fix_all_socket_lists(): fix_socket_list tcp failed
failed to initialize list addresses

SIP Traffic

N/A

Possible Solutions

Don't use listen addresses longer than 70 chars.

Additional Information

version: kamailio 5.2.2 (x86_64/linux) 
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, 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
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 6.3.0
Debian GNU/Linux 9 (stretch)
Linux 75dbf08c8303 5.0.3-arch1-1-ARCH #1 SMP PREEMPT Tue Mar 19 13:09:13 UTC 2019 x86_64 GNU/Linux


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.