<!-- 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 -->
- [ ] Commit message has the format required by CONTRIBUTING guide
- [ ] Commits are split per component (core, individual modules, libs, utils, ...)
- [ ] Each component has a single commit (if not, squash them into one commit)
- [ ] 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 -->
- [x] PR should be backported to stable branches
- [x] Tested changes locally
- [x] Related to issue #3350
#### Description
<!-- Describe your changes in detail -->
This PR fixes a crash when `dns_cache_init=off`.
The issue is described in #3350 and the crash is caused when trying to search in `dns_cache.c` [LOCK_DNS_HASH();](https://github.com/kamailio/kamailio/blob/d4629be286fc6d3….
When `dns_cache_init=off`, the lock is never initialized and when trying to lock it crashes.
Per my understanding, when `dns_cache_init=off`, no calls to `dns_cache.c` should be made and instead call the alternative ones from `resolve.c`, since the whole functions are compiled only when USE_DNS_CACHE definition is present.
Just a question to clarify, what is the reasoning behind USE_DNS_CACHE definition and a separate `dns_cache_init` parameter?
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3858
-- Commit Summary --
* core/resolve: Check dns_cache_init and choose appropriate functions
-- File Changes --
M src/core/resolve.c (16)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3858.patchhttps://github.com/kamailio/kamailio/pull/3858.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3858
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3858(a)github.com>
Module: kamailio
Branch: master
Commit: 06d583e356351ae9d8a559c9f5de3e57fb128a38
URL: https://github.com/kamailio/kamailio/commit/06d583e356351ae9d8a559c9f5de3e5…
Author: Xenofon Karamanos <22965395+xkaraman(a)users.noreply.github.com>
Committer: Xenofon Karamanos <22965395+xkaraman(a)users.noreply.github.com>
Date: 2024-06-04T12:41:58+03:00
core/resolve: Check dns_cache_init and choose appropriate functions
---
Modified: src/core/resolve.c
Modified: src/core/resolve.h
---
Diff: https://github.com/kamailio/kamailio/commit/06d583e356351ae9d8a559c9f5de3e5…
Patch: https://github.com/kamailio/kamailio/commit/06d583e356351ae9d8a559c9f5de3e5…
---
diff --git a/src/core/resolve.c b/src/core/resolve.c
index 6d581f4915f..da247952fd9 100644
--- a/src/core/resolve.c
+++ b/src/core/resolve.c
@@ -1623,7 +1623,11 @@ struct hostent *no_naptr_srv_sip_resolvehost(
srv_name.s = tmp_srv;
srv_name.len = strlen(tmp_srv);
#ifdef USE_DNS_CACHE
- he = dns_srv_get_he(&srv_name, port, dns_flags);
+ if(dns_cache_init) {
+ he = dns_srv_get_he(&srv_name, port, dns_flags);
+ } else {
+ he = srv_sip_resolvehost(&srv_name, 0, port, proto, 1, 0);
+ }
#else
he = srv_sip_resolvehost(&srv_name, 0, port, proto, 1, 0);
#endif
@@ -1660,6 +1664,7 @@ struct hostent *naptr_sip_resolvehost(
struct rdata *naptr_head;
char n_proto;
str srv_name;
+ str *name_copy = 0;
naptr_bmp_t tried_bmp; /* tried bitmap */
char origproto = PROTO_NONE;
@@ -1704,7 +1709,15 @@ struct hostent *naptr_sip_resolvehost(
he = no_naptr_srv_sip_resolvehost(name, port, proto);
/* fallback all the way down to A/AAAA */
if(he == 0) {
- he = dns_get_he(name, dns_flags);
+ if(dns_cache_init) {
+ he = dns_get_he(name, dns_flags);
+ } else {
+ /* We need a zero terminated char* */
+ name_copy = shm_malloc(name->len + 1);
+ shm_str_dup(name_copy, name);
+ he = resolvehost(name_copy->s);
+ shm_free(name_copy);
+ }
}
end:
if(naptr_head)
@@ -1833,6 +1846,45 @@ ip_addr_t *str2ip(str *st)
return ipb;
}
+/*
+* Resolve a host name to a hostent.
+* @param[in] name: the host name to resolve
+* @return the hostent structure or NULL on error
+*
+* @note
+* This function is a wrapper to choose between the DNS cache and the
+* system resolver. If the DNS cache is enabled, it will use the DNS cache
+* to resolve the host name. Otherwise, it will use the system resolver.
+*/
+struct hostent *__resolvehost(char *name)
+{
+ if(dns_cache_init) {
+ return dns_resolvehost(name);
+ } else {
+ return _resolvehost(name);
+ }
+}
+
+/*
+* Resolve a host name to a hostent.
+* @param[in] name: the host name to resolve
+* @param[in] port: the port number
+* @param[in] proto: the protocol
+* @return the hostent structure or NULL on error
+*
+* @note
+* This function is a wrapper to choose between the DNS cache and the
+* system resolver. If the DNS cache is enabled, it will use the DNS cache
+* to resolve the host name. Otherwise, it will use the system resolver.
+*/
+struct hostent *__sip_resolvehost(str *name, unsigned short *port, char *proto)
+{
+ if(dns_cache_init) {
+ return dns_sip_resolvehost(name, port, proto);
+ } else {
+ return _sip_resolvehost(name, port, proto);
+ }
+}
/* converts a str to an ipv6 address struct stored in ipb
* - ipb must be already allocated
* - return 0 on success; <0 on failure */
diff --git a/src/core/resolve.h b/src/core/resolve.h
index c39d90c2104..0e66a7b4ae0 100644
--- a/src/core/resolve.h
+++ b/src/core/resolve.h
@@ -329,14 +329,14 @@ int sip_hostport2su(
union sockaddr_union *su, str *host, unsigned short port, char *proto);
+/* Wrapper functions that check for dns_cache_init */
+struct hostent *__resolvehost(char *name);
+struct hostent *__sip_resolvehost(str *name, unsigned short *port, char *proto);
+
+
/* wrappers */
-#ifdef USE_DNS_CACHE
-#define resolvehost dns_resolvehost
-#define sip_resolvehost dns_sip_resolvehost
-#else
-#define resolvehost _resolvehost
-#define sip_resolvehost _sip_resolvehost
-#endif
+#define resolvehost __resolvehost
+#define sip_resolvehost __sip_resolvehost
#ifdef USE_NAPTR
@Sergey-safarov
Both EL distros 8.10 and 9.4 have been released with Python 3.12.
Can you consider updating bumping the Python version to 3.12 for the
upcoming 5.8.2 release.
Thank you.
Richard Chan
### Description
When configured `read_sdp_pv` param for rtpengine module, then multipart content dropped in the body.
And the message cannot be parsed because
```
Content-Type: multipart/mixed;boundary=level3-boundary
```
But the message body does not have a separator.
### Troubleshooting
#### Reproduction
To reproduce need to start Kamailio with config file
```
loadmodule "pv.so"
loadmodule "ctl.so"
loadmodule "corex.so"
loadmodule "sdpops.so"
loadmodule "rtpengine.so"
modparam("rtpengine", "rtpengine_sock", "udp:localhost:2223")
modparam("rtpengine", "read_sdp_pv", "$var(sdp_for_rtpengine)")
listen=udp:x.x.x.x:5060
request_route {
$var(sdp_for_rtpengine) = $sdp(body);
rtpengine_manage("ICE=force");
forward();
}
```
And then send call using `sipp` script
```xml
<scenario name="Basic Sipstone UAC">
<!-- In client mode (sipp placing calls), the Call-ID MUST be -->
<!-- generated by sipp. To do so, use [call_id] keyword. -->
<send retrans="500">
<![CDATA[
INVITE sip:[service]@example.com:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
To: sut <sip:[service]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:sipp@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Type: multipart/mixed;boundary=level3-boundary
Content-Length: [len]
--level3-boundary
Content-Type: application/sdp
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
--level3-boundary
Content-Type: application/isup;version=ansi
Content-Disposition: session;handling=optional
\x01\x18\x08\x10\x0a\x03\x06\x0d\x03\x80\x90\xa2\x07\x03\x10\x87\x36\x08\x14\x89
\x0a\x07\x03\x13\x27\x97\x45\x28\x49\xc0\x08\xc0\x03\x10\x65\x41\x17\x88\x67\x3d
\x01\x11\xc4\x03\x01\x01\x00\xea\x01\x01\xc7\x01\x20\x01\x0d\x0a
--level3-boundary--
]]>
</send>
```
If the `read_sdp_pv` param will be commented in the Kamailio config file, then the resulting message will be properly formatted and have the other multipart media.
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3854
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3854(a)github.com>