[SR-Dev] git:ser_core_cvs: dns: fix selecting neg. cname entry

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Apr 3 16:05:09 CEST 2009


Module: sip-router
Branch: ser_core_cvs
Commit: 25ba1f0f4cd2b059e3f2a27d619ca054122cf4cb
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=25ba1f0f4cd2b059e3f2a27d619ca054122cf4cb

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Tue Mar 31 18:11:25 2009 +0000

dns: fix selecting neg. cname entry

- do not select a neg. cache cname entry as a response, unless
  the request is for a cname.
  This fixes an unlikely bug: someone makes a specific cname
  request (from ser) for a name that doesn't resolve and then later when
  a normal non-cname request is made (e.g. A) the empty negative cname
  entry is selected, leading to a coredump. So far there is no
  code in ser that could trigger this bug. Only dns.lookup cname
  ... from sip-router could trigger it.

---

 dns_cache.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/dns_cache.c b/dns_cache.c
index b0e7a4d..a5167c4 100644
--- a/dns_cache.c
+++ b/dns_cache.c
@@ -580,8 +580,11 @@ again:
 #endif
 #endif
 			return e;
-		}else if ((e->type==T_CNAME) && (e->name_len==name->len) &&
-			(strncasecmp(e->name, name->s, e->name_len)==0)){
+		}else if ((e->type==T_CNAME) && !((e->rr_lst==0) || e->err_flags) &&
+					(e->name_len==name->len) &&
+					(strncasecmp(e->name, name->s, e->name_len)==0)){
+			/*if CNAME matches and CNAME is entry is not a neg. cache entry
+			  (could be produced by a specific CNAME lookup)*/
 			e->last_used=now;
 #ifdef DNS_LU_LST
 			/* add it at the end */




More information about the sr-dev mailing list