Changeset 6000


Ignore:
Timestamp:
May 23, 2019 1:42:27 PM (11 months ago)
Author:
riza
Message:

Close #2200: Ignore/discard DNS SRV response with truncated flag set.

Location:
pjproject/trunk/pjlib-util/src/pjlib-util
Files:
2 edited

Legend:

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

    r5981 r6000  
    17771777    pj_grp_lock_acquire(resolver->grp_lock); 
    17781778 
    1779     /* Save/update response cache. */ 
    1780     update_res_cache(resolver, &q->key, status, PJ_TRUE, dns_pkt); 
    1781      
     1779    /* Truncated responses MUST NOT be saved (cached). */ 
     1780    if (PJ_DNS_GET_TC(dns_pkt->hdr.flags) == 0) { 
     1781        /* Save/update response cache. */ 
     1782        update_res_cache(resolver, &q->key, status, PJ_TRUE, dns_pkt); 
     1783    } 
     1784 
    17821785    /* Recycle query objects, starting with the child queries */ 
    17831786    if (!pj_list_empty(&q->child_head)) { 
  • pjproject/trunk/pjlib-util/src/pjlib-util/srv_resolver.c

    r5996 r6000  
    586586        query_job->q_srv = NULL; 
    587587 
    588         if (status == PJ_SUCCESS && pkt->hdr.anscount != 0) { 
    589             /* Got SRV response, build server entry. If A records are available 
    590              * in additional records section of the DNS response, save them too. 
    591              */ 
    592             build_server_entries(query_job, pkt); 
    593  
    594         } else if (status != PJ_SUCCESS) { 
     588        if (status == PJ_SUCCESS) { 
     589            if (PJ_DNS_GET_TC(pkt->hdr.flags)) { 
     590                /* Got truncated answer, the standard recommends to follow up 
     591                 * the query using TCP. Since we currently don't support it, 
     592                 * just return error. 
     593                 */ 
     594                PJ_LOG(4,(query_job->objname, 
     595                          "Discard truncated DNS SRV response for %.*s", 
     596                          (int)query_job->full_name.slen, 
     597                          query_job->full_name.ptr)); 
     598 
     599                status = PJ_EIGNORED; 
     600                query_job->last_error = status; 
     601                goto on_error; 
     602            } else if (pkt->hdr.anscount != 0) { 
     603                /* Got SRV response, build server entry. If A records are 
     604                 * available in additional records section of the DNS response, 
     605                 * save them too. 
     606                 */ 
     607                build_server_entries(query_job, pkt); 
     608            } 
     609 
     610        } else { 
    595611            char errmsg[PJ_ERR_MSG_SIZE]; 
    596612 
Note: See TracChangeset for help on using the changeset viewer.