Ticket #3172: glibc-test.patch

File glibc-test.patch, 1.6 KB (added by bdubbs@…, 12 years ago)
  • resolv/res_query.c

    old new  
    122122                  int *resplen2)
    123123{
    124124        HEADER *hp = (HEADER *) answer;
     125        HEADER *hp2;
    125126        int n, use_malloc = 0;
    126127        u_int oflags = statp->_flags;
    127128
     
    239240          /* __libc_res_nsend might have reallocated the buffer.  */
    240241          hp = (HEADER *) *answerp;
    241242
    242         /* We simplify the following tests by assigning HP to HP2.  It
    243            is easy to verify that this is the same as ignoring all
    244            tests of HP2.  */
    245         HEADER *hp2 = answerp2 ? (HEADER *) *answerp2 : hp;
    246 
    247         if (n < (int) sizeof (HEADER) && answerp2 != NULL
    248             && *resplen2 > (int) sizeof (HEADER))
     243   /* We simplify the following tests by assigning HP to HP2 or
     244      vice versa.  It is easy to verify that this is the same as
     245      ignoring all tests of HP or HP2.  */
     246   if (answerp2 == NULL || *resplen2 < (int) sizeof (HEADER))
    249247          {
    250248            /* Special case of partial answer.  */
    251249            assert (hp != hp2);
    252250            hp = hp2;
     251       hp2 = hp;
    253252          }
    254         else if (answerp2 != NULL && *resplen2 < (int) sizeof (HEADER)
    255                  && n > (int) sizeof (HEADER))
     253        else
    256254          {
    257255            /* Special case of partial answer.  */
    258             assert (hp != hp2);
    259256            hp2 = hp;
     257            hp2 = (HEADER *) *answerp2;
     258            if (n < (int) sizeof (HEADER))
     259              {
     260                hp = hp2;
     261              }
    260262          }
    261263
     264        /* Make sure both hp and hp2 are defined */
     265        assert((hp != NULL) && (hp2 != NULL));
     266
    262267        if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0)
    263268            && (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) {
    264269#ifdef DEBUG