Articles‎ > ‎DJBDNS‎ > ‎

DJBDNS patch to show more than 8 results for A record request.

By default DJBDNS does not show more than 8 results for A type of request. That can be changed with a simple patch (which bumps this to 64).

*** tdlookup.c.orig     Sun Feb 11 13:11:45 2001
--- tdlookup.c  Tue Mar 22 20:44:49 2005
***************
*** 9,14 ****
--- 9,16 ----
  #include "seek.h"
  #include "response.h"

+ #define MAX_A 64
+
  static int want(const char *owner,const char type[2])
  {
    unsigned int pos;
***************
*** 118,124 ****
    int flagauthoritative;
    char x[20];
    uint16 u16;
!   char addr[8][4];
    int addrnum;
    uint32 addrttl;
    int i;
--- 120,126 ----
    int flagauthoritative;
    char x[20];
    uint16 u16;
!   char addr[MAX_A][4];
    int addrnum;
    uint32 addrttl;
    int i;
***************
*** 163,170 ****
        if (byte_equal(type,2,DNS_T_A) && (dlen - dpos == 4)) {
        addrttl = ttl;
        i = dns_random(addrnum + 1);
!       if (i < 8) {
!         if ((i < addrnum) && (addrnum < 8))
            byte_copy(addr[addrnum],4,addr[i]);
          byte_copy(addr[i],4,data + dpos);
        }
--- 165,172 ----
        if (byte_equal(type,2,DNS_T_A) && (dlen - dpos == 4)) {
        addrttl = ttl;
        i = dns_random(addrnum + 1);
!       if (i < MAX_A) {
!         if ((i < addrnum) && (addrnum < MAX_A))
            byte_copy(addr[addrnum],4,addr[i]);
          byte_copy(addr[i],4,data + dpos);
        }
***************
*** 190,196 ****
        response_rfinish(RESPONSE_ANSWER);
      }
      for (i = 0;i < addrnum;++i)
!       if (i < 8) {
        if (!response_rstart(q,DNS_T_A,addrttl)) return 0;
        if (!response_addbytes(addr[i],4)) return 0;
        response_rfinish(RESPONSE_ANSWER);
--- 192,198 ----
        response_rfinish(RESPONSE_ANSWER);
      }
      for (i = 0;i < addrnum;++i)
!       if (i < MAX_A) {
        if (!response_rstart(q,DNS_T_A,addrttl)) return 0;
        if (!response_addbytes(addr[i],4)) return 0;
        response_rfinish(RESPONSE_ANSWER);

Comments