I had sent the patch as attachment, but it was removed from my message,
so I send it again, nut now in the message body.

Arnold

ChangeLog
* freshclam/dns.c (txtquery): Try an ANY-query if the TXT-query has failed; 
workaround for defective DNS servers as found in Alcatel SpeedTouch modems.

--- freshclam/dns.c     2006-04-09 21:59:27.000000000 +0200
+++ freshclam/dns.c.new 2006-08-17 19:52:33.000000000 +0200
@@ -43,7 +43,7 @@
 char *txtquery(const char *domain, unsigned int *ttl)
 {
        unsigned char answer[PACKETSZ], host[128], *pt, *txt;
-       int len, exp, cttl, size, txtlen, type;
+       int len, exp, cttl, size, txtlen, type, qtype;
 
 
     if(res_init() < 0) {
@@ -54,9 +54,19 @@ char *txtquery(const char *domain, unsig
     logg("*Querying %s\n", domain);
 
     memset(answer, 0, PACKETSZ);
-    if((len = res_query(domain, C_IN, T_TXT, answer, PACKETSZ)) < 0) {
-       logg("^Can't query %s\n", domain);
-       return NULL;
+    qtype = T_TXT;
+    if((len = res_query(domain, C_IN, qtype, answer, PACKETSZ)) < 0) {
+       /*  The DNS server in the SpeedTouch Alcatel 510 modem can't
+        *  handle a TXT-query, but it can resolve an ANY-query to a
+        *  TXT-record, so we try an ANY-query now.  The thing we try
+        *  to resolve normally only has a TXT-record anyway.  
+        */
+       memset(answer, 0, PACKETSZ);
+       qtype=T_ANY;
+       if((len = res_query(domain, C_IN, qtype, answer, PACKETSZ)) < 0) {
+           logg("^Can't query %s\n", domain);
+           return NULL;
+       }
     }
 
     pt = answer + sizeof(HEADER);
@@ -69,7 +79,7 @@ char *txtquery(const char *domain, unsig
     pt += exp;
 
     GETSHORT(type, pt);
-    if(type != T_TXT) {
+    if(type != qtype) {
        logg("^Broken DNS reply.\n");
        return NULL;
     }
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html

Reply via email to