[sr-dev] git:master:703d6202: core: resolve - safety check for setting port

Daniel-Constantin Mierla miconda at gmail.com
Thu Apr 15 08:33:16 CEST 2021


Module: kamailio
Branch: master
Commit: 703d6202e73e4e3778a2c66f4e29ae87dc6ac211
URL: https://github.com/kamailio/kamailio/commit/703d6202e73e4e3778a2c66f4e29ae87dc6ac211

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-04-15T08:32:38+02:00

core: resolve - safety check for setting port

---

Modified: src/core/resolve.c

---

Diff:  https://github.com/kamailio/kamailio/commit/703d6202e73e4e3778a2c66f4e29ae87dc6ac211.diff
Patch: https://github.com/kamailio/kamailio/commit/703d6202e73e4e3778a2c66f4e29ae87dc6ac211.patch

---

diff --git a/src/core/resolve.c b/src/core/resolve.c
index deb20a740c..c2ea36d9ec 100644
--- a/src/core/resolve.c
+++ b/src/core/resolve.c
@@ -1225,7 +1225,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.
@@ -1313,7 +1313,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");
@@ -1325,7 +1325,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;
 				}
@@ -1344,7 +1344,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;
 				}
@@ -1356,7 +1356,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);
 		}
 	}




More information about the sr-dev mailing list