Symptoms:
Host www.kk.org has both AAAA and CNAME -- ignoring CNAME.
Host www.kk.org has both AAAA and CNAME -- ignoring CNAME.
Host www.kk.org has both AAAA and CNAME -- ignoring CNAME.
Host www.kk.org lookup failed: Timeout (131072).
Cause:
Polipo sends two DNS queries in paralell for A (ipv4) and AAAA
(ipv6). Here's what causes the above error:
polipo: query 1: A
polipo: query 2: AAAA
dns: response to 2: no error, but also no answers
(i.e. domain exists but is not an IPV6 address)
dns: response to 1: CNAME (a redirect to a different domain name)
Fix:
Don't allow responses to an AAAA query to override CNAME if the
AAAA response doesn't actually include an address.
The fix itself only affects a single if statement. The remaining
bulk of the patch is needed to correct the same issue in an
assertion further down.
diff --git a/dns.c b/dns.c
index 8d4ac75..d126857 100644
diff --git a/dns.c b/dns.c
index 8d4ac75..8c8f160 100644
--- a/dns.c
+++ b/dns.c
@@ -1181,7 +1181,8 @@ dnsReplyHandler(int abort, FdEventHandlerPtr event)
} else
releaseAtom(value);
} else if(af == 0) {
- if(query->inet4 || query->inet6) {
+ if((query->inet4 && query->inet4->length > 0) ||
+ (query->inet6 && query->inet6->length > 0)) {
do_log(L_WARN, "Host %s has both %s and CNAME -- "
"ignoring CNAME.\n", scrub(query->name->string),
query->inet4 ? "A" : "AAAA");
@@ -1206,24 +1207,29 @@ dnsReplyHandler(int abort, FdEventHandlerPtr event)
if(object->flags & OBJECT_INITIAL) {
assert(!object->headers);
+
+ if (query->inet4 && query->inet4->length == 0) {
+ releaseAtom(query->inet4);
+ query->inet4 = NULL;
+ }
+ if (query->inet6 && query->inet6->length == 0) {
+ releaseAtom(query->inet6);
+ query->inet6 = NULL;
+ }
+
if(cname) {
- assert(query->inet4 == NULL && query->inet6 == NULL);
+ assert(!query->inet4 && !query->inet6);
object->headers = cname;
object->expires = current_time.tv_sec + ttl;
- } else if((!query->inet4 || query->inet4->length == 0) &&
- (!query->inet6 || query->inet6->length == 0)) {
- releaseAtom(query->inet4);
- releaseAtom(query->inet6);
+ } else if(!query->inet4 && !query->inet6) {
object->expires = current_time.tv_sec + dnsNegativeTtl;
abortObject(object, 500, retainAtom(message));
- } else if(!query->inet4 || query->inet4->length == 0) {
+ } else if(!query->inet4) {
object->headers = query->inet6;
object->expires = query->ttl6;
- releaseAtom(query->inet4);
- } else if(!query->inet6 || query->inet6->length == 0) {
+ } else if(!query->inet6) {
object->headers = query->inet4;
object->expires = query->ttl4;
- releaseAtom(query->inet6);
} else {
/* need to merge results */
char buf[1024];
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Polipo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/polipo-users