[sr-dev] git:5.0:11300211: core: make dns name to IP conversion more robust for IPv4 and IPv6

Henning Westerholt hw at kamailio.org
Fri Jun 8 21:20:44 CEST 2018


Module: kamailio
Branch: 5.0
Commit: 11300211d6562aafc654a778f25657f001a39790
URL: https://github.com/kamailio/kamailio/commit/11300211d6562aafc654a778f25657f001a39790

Author: Henning Westerholt <hw at kamailio.org>
Committer: Henning Westerholt <hw at kamailio.org>
Date: 2018-06-08T21:20:32+02:00

core: make dns name to IP conversion more robust for IPv4 and IPv6

(cherry picked from commit 4a55a2b40b91f282d7fd8f0e3c3ae22bcf56d9dc)

---

Modified: src/core/resolve.h

---

Diff:  https://github.com/kamailio/kamailio/commit/11300211d6562aafc654a778f25657f001a39790.diff
Patch: https://github.com/kamailio/kamailio/commit/11300211d6562aafc654a778f25657f001a39790.patch

---

diff --git a/src/core/resolve.h b/src/core/resolve.h
index fad783e4e6..30cce19581 100644
--- a/src/core/resolve.h
+++ b/src/core/resolve.h
@@ -229,6 +229,10 @@ static inline struct ip_addr* str2ip(str* st)
 	static struct ip_addr ip;
 	unsigned char* s;
 
+	/* just in case that e.g. the VIA parser get confused */
+	if(unlikely(!st->s || st->len <= 0)) {
+		LM_ERR("invalid name, no conversion to IP address possible\n");
+	}
 	s=(unsigned char*)st->s;
 
 	/*init*/
@@ -281,6 +285,10 @@ static inline struct ip_addr* str2ip6(str* st)
 	unsigned char* limit;
 	unsigned char* s;
 	
+	/* just in case that e.g. the VIA parser get confused */
+	if(unlikely(!st->s || st->len <= 0)) {
+		LM_ERR("invalid name, no conversion to IP address possible\n");
+	}
 	/* init */
 	if ((st->len) && (st->s[0]=='[')){
 		/* skip over [ ] */




More information about the sr-dev mailing list