source: npl/mailserver/netqmail/qmail-103.patch @ 0105685

gcc484ntopperl-5.22
Last change on this file since 0105685 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.1 KB
  • qmail-1.03/dns.c

    old new  
    2121static unsigned short getshort(c) unsigned char *c;
    2222{ unsigned short u; u = c[0]; return (u << 8) + c[1]; }
    2323
    24 static union { HEADER hdr; unsigned char buf[PACKETSZ]; } response;
     24static struct { unsigned char *buf; } response;
     25static int responsebuflen = 0;
    2526static int responselen;
    2627static unsigned char *responseend;
    2728static unsigned char *responsepos;
     29static u_long saveresoptions;
    2830
    2931static int numanswers;
    3032static char name[MAXDNAME];
     
    4547 errno = 0;
    4648 if (!stralloc_copy(&glue,domain)) return DNS_MEM;
    4749 if (!stralloc_0(&glue)) return DNS_MEM;
    48  responselen = lookup(glue.s,C_IN,type,response.buf,sizeof(response));
     50 if (!responsebuflen)
     51  if (response.buf = (unsigned char *)alloc(PACKETSZ+1))
     52   responsebuflen = PACKETSZ+1;
     53  else return DNS_MEM;
     54
     55 responselen = lookup(glue.s,C_IN,type,response.buf,responsebuflen);
     56 if ((responselen >= responsebuflen) ||
     57     (responselen > 0 && (((HEADER *)response.buf)->tc)))
     58  {
     59   if (responsebuflen < 65536)
     60    if (alloc_re(&response.buf, responsebuflen, 65536))
     61     responsebuflen = 65536;
     62    else return DNS_MEM;
     63    saveresoptions = _res.options;
     64    _res.options |= RES_USEVC;
     65    responselen = lookup(glue.s,C_IN,type,response.buf,responsebuflen);
     66    _res.options = saveresoptions;
     67  }
    4968 if (responselen <= 0)
    5069  {
    5170   if (errno == ECONNREFUSED) return DNS_SOFT;
    5271   if (h_errno == TRY_AGAIN) return DNS_SOFT;
    5372   return DNS_HARD;
    5473  }
    55  if (responselen >= sizeof(response))
    56    responselen = sizeof(response);
    5774 responseend = response.buf + responselen;
    5875 responsepos = response.buf + sizeof(HEADER);
    59  n = ntohs(response.hdr.qdcount);
     76 n = ntohs(((HEADER *)response.buf)->qdcount);
    6077 while (n-- > 0)
    6178  {
    6279   i = dn_expand(response.buf,responseend,responsepos,name,MAXDNAME);
     
    6683   if (i < QFIXEDSZ) return DNS_SOFT;
    6784   responsepos += QFIXEDSZ;
    6885  }
    69  numanswers = ntohs(response.hdr.ancount);
     86 numanswers = ntohs(((HEADER *)response.buf)->ancount);
    7087 return 0;
    7188}
    7289
Note: See TracBrowser for help on using the repository browser.