瀏覽代碼

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.
Andrei Pelinescu-Onciul 16 年之前
父節點
當前提交
25ba1f0f4c
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      dns_cache.c

+ 5 - 2
dns_cache.c

@@ -580,8 +580,11 @@ again:
 #endif
 #endif
 #endif
 #endif
 			return e;
 			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;
 			e->last_used=now;
 #ifdef DNS_LU_LST
 #ifdef DNS_LU_LST
 			/* add it at the end */
 			/* add it at the end */