Explorar o código

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

Henning Westerholt %!s(int64=7) %!d(string=hai) anos
pai
achega
4a55a2b40b
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      src/core/resolve.h

+ 8 - 0
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 [ ] */