浏览代码

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

Henning Westerholt 7 年之前
父节点
当前提交
4a55a2b40b
共有 1 个文件被更改,包括 8 次插入0 次删除
  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;
 	static struct ip_addr ip;
 	unsigned char* s;
 	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;
 	s=(unsigned char*)st->s;
 
 
 	/*init*/
 	/*init*/
@@ -281,6 +285,10 @@ static inline struct ip_addr* str2ip6(str* st)
 	unsigned char* limit;
 	unsigned char* limit;
 	unsigned char* s;
 	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 */
 	/* init */
 	if ((st->len) && (st->s[0]=='[')){
 	if ((st->len) && (st->s[0]=='[')){
 		/* skip over [ ] */
 		/* skip over [ ] */