Module: kamailio
Branch: 5.4
Commit: 1e6561f86d4a139834952ff21b74ecca0b508966
URL:
https://github.com/kamailio/kamailio/commit/1e6561f86d4a139834952ff21b74ecc…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-04-15T08:35:40+02:00
core: resolve - safety check for setting port
(cherry picked from commit 703d6202e73e4e3778a2c66f4e29ae87dc6ac211)
---
Modified: src/core/resolve.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1e6561f86d4a139834952ff21b74ecc…
Patch:
https://github.com/kamailio/kamailio/commit/1e6561f86d4a139834952ff21b74ecc…
---
diff --git a/src/core/resolve.c b/src/core/resolve.c
index 3796f05ceb..cfed6b5e1d 100644
--- a/src/core/resolve.c
+++ b/src/core/resolve.c
@@ -1211,7 +1211,7 @@ int naptr_choose (struct naptr_rdata** crt, char* crt_proto,
* and *proto!=0 or port==0 && proto==0)
* when performing SRV lookup (*port==0) it will use *proto to look for
* tcp or udp hosts, otherwise proto is unused; if proto==0 => no SRV lookup
- * If zt is set, name will be assumed to be 0 terminated and some copy
+ * If zt is set, name will be assumed to be 0 terminated and some copy
* operations will be avoided.
* If is_srv is set it will assume name has the srv prefixes for sip already
* appended and it's already 0-term'ed; if not it will append them internally.
@@ -1299,7 +1299,7 @@ struct hostent* srv_sip_resolvehost(str* name, int zt, unsigned
short* port,
do_srv:
/* try to find the SRV records inside previous ARs first*/
for (l=ars; l; l=l->next){
- if (l->type!=T_SRV) continue;
+ if (l->type!=T_SRV) continue;
srv=(struct srv_rdata*) l->rdata;
if (srv==0){
LM_CRIT("null rdata\n");
@@ -1311,7 +1311,7 @@ struct hostent* srv_sip_resolvehost(str* name, int zt, unsigned
short* port,
/* we found it*/
LM_DBG("found SRV(%s) = %s:%d in AR\n",
srv_target, srv->name, srv->port);
- *port=srv->port;
+ if(port) *port=srv->port;
/* cleanup on exit */
goto end;
}
@@ -1330,7 +1330,7 @@ struct hostent* srv_sip_resolvehost(str* name, int zt, unsigned
short* port,
/* we found it*/
LM_DBG("SRV(%s) = %s:%d\n",
srv_target, srv->name, srv->port);
- *port=srv->port;
+ if(port) *port=srv->port;
/* cleanup on exit */
goto end;
}
@@ -1342,7 +1342,7 @@ struct hostent* srv_sip_resolvehost(str* name, int zt, unsigned
short* port,
goto end;
}
/* cleanup on exit */
- LM_DBG("no SRV record found for %.*s,"
+ LM_DBG("no SRV record found for %.*s,"
" trying 'normal' lookup...\n", name->len, name->s);
}
}