source: npl/internetserver/djbdns/CVE2008-4392_0002-dnscache-cache-soa-records.patch @ 9c8fcb1

gcc484perl-5.22
Last change on this file since 9c8fcb1 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 2.9 KB
  • query.c

    diff --git a/query.c b/query.c
    index 46cdc00..4574e97 100644
    a b static int doit(struct query *z,int state) 
    319319      }
    320320    }
    321321
     322    if (typematch(DNS_T_SOA,dtype)) {
     323      byte_copy(key,2,DNS_T_SOA);
     324      cached = cache_get(key,dlen + 2,&cachedlen,&ttl);
     325      if (cached && (cachedlen || byte_diff(dtype,2,DNS_T_ANY))) {
     326        log_cachedanswer(d,DNS_T_SOA);
     327        if (!rqa(z)) goto DIE;
     328        pos = 0;
     329        while (pos = dns_packet_copy(cached,cachedlen,pos,misc,20)) {
     330          pos = dns_packet_getname(cached,cachedlen,pos,&t2);
     331          if (!pos) break;
     332          pos = dns_packet_getname(cached,cachedlen,pos,&t3);
     333          if (!pos) break;
     334          if (!response_rstart(d,DNS_T_SOA,ttl)) goto DIE;
     335          if (!response_addname(t2)) goto DIE;
     336          if (!response_addname(t3)) goto DIE;
     337          if (!response_addbytes(misc,20)) goto DIE;
     338          response_rfinish(RESPONSE_ANSWER);
     339        }
     340        cleanup(z);
     341        return 1;
     342      }
     343    }
     344
    322345    if (typematch(DNS_T_A,dtype)) {
    323346      byte_copy(key,2,DNS_T_A);
    324347      cached = cache_get(key,dlen + 2,&cachedlen,&ttl);
    static int doit(struct query *z,int state) 
    351374      }
    352375    }
    353376
    354     if (!typematch(DNS_T_ANY,dtype) && !typematch(DNS_T_AXFR,dtype) && !typematch(DNS_T_CNAME,dtype) && !typematch(DNS_T_NS,dtype) && !typematch(DNS_T_PTR,dtype) && !typematch(DNS_T_A,dtype) && !typematch(DNS_T_MX,dtype)) {
     377    if (!typematch(DNS_T_ANY,dtype) && !typematch(DNS_T_AXFR,dtype) && !typematch(DNS_T_CNAME,dtype) && !typematch(DNS_T_NS,dtype) && !typematch(DNS_T_PTR,dtype) && !typematch(DNS_T_A,dtype) && !typematch(DNS_T_MX,dtype) && !typematch(DNS_T_SOA,dtype)) {
    355378      byte_copy(key,2,dtype);
    356379      cached = cache_get(key,dlen + 2,&cachedlen,&ttl);
    357380      if (cached && (cachedlen || byte_diff(dtype,2,DNS_T_ANY))) {
    static int doit(struct query *z,int state) 
    585608    else if (byte_equal(type,2,DNS_T_AXFR))
    586609      ;
    587610    else if (byte_equal(type,2,DNS_T_SOA)) {
     611      int non_authority = 0;
     612      save_start();
    588613      while (i < j) {
    589614        pos = dns_packet_skipname(buf,len,records[i]); if (!pos) goto DIE;
    590615        pos = dns_packet_getname(buf,len,pos + 10,&t2); if (!pos) goto DIE;
    591616        pos = dns_packet_getname(buf,len,pos,&t3); if (!pos) goto DIE;
    592617        pos = dns_packet_copy(buf,len,pos,misc,20); if (!pos) goto DIE;
    593         if (records[i] < posauthority)
     618        if (records[i] < posauthority) {
    594619          log_rrsoa(whichserver,t1,t2,t3,misc,ttl);
     620          save_data(misc,20);
     621          save_data(t2,dns_domain_length(t2));
     622          save_data(t3,dns_domain_length(t3));
     623          non_authority++;
     624        }
    595625        ++i;
    596626      }
     627      if (non_authority)
     628        save_finish(DNS_T_SOA,t1,ttl);
    597629    }
    598630    else if (byte_equal(type,2,DNS_T_CNAME)) {
    599631      pos = dns_packet_skipname(buf,len,records[j - 1]); if (!pos) goto DIE;
Note: See TracBrowser for help on using the repository browser.