Changeset 3346


Ignore:
Timestamp:
Oct 14, 2010 10:56:02 AM (11 years ago)
Author:
bennylp
Message:

Misc (re #1134): fixed failed unit tests due to changes in DNS resolver code in r3344

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/src/pjlib-util/resolver.c

    r3344 r3346  
    843843{ 
    844844    enum { MAX_SEARCH = 20 }; 
    845     pj_str_t hostname, alias = {NULL, 0}; 
     845    pj_str_t hostname, alias = {NULL, 0}, *resname; 
    846846    unsigned bufstart = 0; 
    847847    unsigned bufleft = sizeof(rec->buf_); 
     
    889889        return PJLIB_UTIL_EDNSNOANSWERREC; 
    890890 
     891    resname = &hostname; 
     892 
    891893    /* Keep following CNAME records. */ 
    892894    while (pkt->ans[ansidx].type == PJ_DNS_TYPE_CNAME && 
    893895           search_cnt++ < MAX_SEARCH) 
    894896    { 
     897        resname = &pkt->ans[ansidx].rdata.cname.name; 
     898 
    895899        if (!alias.slen) 
    896             alias = pkt->ans[ansidx].rdata.cname.name; 
    897  
    898         for (i=ansidx+1; i < pkt->hdr.anscount; ++i) { 
    899             if (pj_stricmp(&pkt->ans[ansidx].rdata.cname.name, 
    900                            &pkt->ans[i].name)==0) 
    901             { 
     900            alias = *resname; 
     901 
     902        for (i=0; i < pkt->hdr.anscount; ++i) { 
     903            if (pj_stricmp(resname, &pkt->ans[i].name)==0) { 
    902904                break; 
    903905            } 
     
    905907 
    906908        if (i==pkt->hdr.anscount) 
    907             return PJLIB_UTIL_EDNSINANSWER; 
     909            return PJLIB_UTIL_EDNSNOANSWERREC; 
    908910 
    909911        ansidx = i; 
     
    929931    } 
    930932 
    931     /* Retrieve the IP address. */ 
    932     if (rec->addr_count < PJ_DNS_MAX_IP_IN_A_REC) { 
    933         rec->addr[rec->addr_count++].s_addr = 
    934             pkt->ans[i].rdata.a.ip_addr.s_addr; 
     933    /* Get the IP addresses. */ 
     934    for (i=0; i < pkt->hdr.anscount; ++i) { 
     935        if (pkt->ans[i].type == PJ_DNS_TYPE_A && 
     936            pj_stricmp(&pkt->ans[i].name, resname)==0 && 
     937            rec->addr_count < PJ_DNS_MAX_IP_IN_A_REC) 
     938        { 
     939            rec->addr[rec->addr_count++].s_addr = 
     940                pkt->ans[i].rdata.a.ip_addr.s_addr; 
     941        } 
    935942    } 
    936943 
Note: See TracChangeset for help on using the changeset viewer.