[sr-dev] git:master: core: dns - prevent queries for IPv4/6 address literals

Daniel-Constantin Mierla miconda at gmail.com
Thu Feb 21 10:43:05 CET 2013


Module: sip-router
Branch: master
Commit: 9e6f0268097d81c0e06c7fe33599d0763ed38179
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9e6f0268097d81c0e06c7fe33599d0763ed38179

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Feb 21 10:40:07 2013 +0100

core: dns - prevent queries for IPv4/6 address literals

- prevent A queries for IPv6 address literals or AAAA queries for IPv4
  address literals
- patch by Simon Perreault

---

 dns_cache.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dns_cache.c b/dns_cache.c
index 1f4ae82..b56e94d 100644
--- a/dns_cache.c
+++ b/dns_cache.c
@@ -1891,6 +1891,8 @@ inline static struct dns_hash_entry* dns_cache_do_request(str* name, int type)
 #endif /* USE_DNS_CACHE_STATS */
 
 	if (type==T_A){
+		if (str2ip6(name)!=0)
+			goto end;
 		if ((ip=str2ip(name))!=0){
 				e=dns_cache_mk_ip_entry(name, ip);
 				if (likely(e))
@@ -1900,6 +1902,8 @@ inline static struct dns_hash_entry* dns_cache_do_request(str* name, int type)
 	}
 #ifdef USE_IPV6
 	else if (type==T_AAAA){
+		if (str2ip(name)!=0)
+			goto end;
 		if ((ip=str2ip6(name))!=0){
 				e=dns_cache_mk_ip_entry(name, ip);
 				if (likely(e))
@@ -2465,6 +2469,8 @@ inline static struct hostent* dns_a_get_he(str* name)
 	struct hostent* he;
 
 	e=0;
+	if (str2ip6(name)!=0)
+		return 0;
 	if ((ip=str2ip(name))!=0){
 		return ip_addr2he(name, ip);
 	}
@@ -2489,6 +2495,8 @@ inline static struct hostent* dns_aaaa_get_he(str* name)
 	struct hostent* he;
 
 	e=0;
+	if (str2ip(name)!=0)
+		return 0;
 	if ((ip=str2ip6(name))!=0){
 		return ip_addr2he(name, ip);
 	}
@@ -2963,6 +2971,8 @@ inline static int dns_a_resolve( struct dns_hash_entry** e,
 	ret=-E_DNS_NO_IP;
 	if (*e==0){ /* do lookup */
 		/* if ip don't set *e */
+		if (str2ip6(name)!=0)
+			goto error;
 		if ((tmp=str2ip(name))!=0){
 			*ip=*tmp;
 			*rr_no=0;
@@ -3012,6 +3022,8 @@ inline static int dns_aaaa_resolve( struct dns_hash_entry** e,
 	ret=-E_DNS_NO_IP;
 	if (*e==0){ /* do lookup */
 		/* if ip don't set *e */
+		if (str2ip(name)!=0)
+			goto error;
 		if ((tmp=str2ip6(name))!=0){
 			*ip=*tmp;
 			*rr_no=0;




More information about the sr-dev mailing list