Changeset 5352


Ignore:
Timestamp:
Jun 21, 2016 10:19:10 AM (8 years ago)
Author:
nanang
Message:

Fix #1935: Avoid shallow-cloning header in SIP registration client as when sending REGISTER message is done asynchronously via DNS SRV resolution, pjsip_regc may get destroyed prematurely and some data allocated by pjsip_regc pool (e.g: Contact header) will become invalid too before the sending process is completed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c

    r5336 r5352  
    522522        while (route != &regc->route_set) { 
    523523            pjsip_hdr *new_hdr = (pjsip_hdr*) 
    524                                  pjsip_hdr_shallow_clone(tdata->pool, route); 
     524                                 pjsip_hdr_clone(tdata->pool, route); 
    525525            pj_list_insert_after(route_pos, new_hdr); 
    526526            route_pos = new_hdr; 
     
    536536        while (hdr != &regc->hdr_list) { 
    537537            pjsip_hdr *new_hdr = (pjsip_hdr*) 
    538                                  pjsip_hdr_shallow_clone(tdata->pool, hdr); 
     538                                 pjsip_hdr_clone(tdata->pool, hdr); 
    539539            pjsip_msg_add_hdr(tdata->msg, new_hdr); 
    540540            hdr = hdr->next; 
     
    575575    while (hdr != &regc->contact_hdr_list) { 
    576576        pjsip_msg_add_hdr(msg, (pjsip_hdr*) 
    577                                pjsip_hdr_shallow_clone(tdata->pool, hdr)); 
     577                               pjsip_hdr_clone(tdata->pool, hdr)); 
    578578        hdr = hdr->next; 
    579579    } 
     
    590590    if (regc->expires_hdr) 
    591591        pjsip_msg_add_hdr(msg, (pjsip_hdr*) 
    592                                pjsip_hdr_shallow_clone(tdata->pool, 
    593                                                        regc->expires_hdr)); 
     592                               pjsip_hdr_clone(tdata->pool, 
     593                                               regc->expires_hdr)); 
    594594 
    595595    if (regc->timer.id != 0) { 
     
    602602    if (h_allow) { 
    603603        pjsip_msg_add_hdr(msg, (pjsip_hdr*) 
    604                                pjsip_hdr_shallow_clone(tdata->pool, h_allow)); 
     604                               pjsip_hdr_clone(tdata->pool, h_allow)); 
    605605 
    606606    } 
     
    647647    while ((void*)hdr != (void*)&regc->contact_hdr_list) { 
    648648        pjsip_msg_add_hdr(msg, (pjsip_hdr*) 
    649                                pjsip_hdr_shallow_clone(tdata->pool, hdr)); 
     649                               pjsip_hdr_clone(tdata->pool, hdr)); 
    650650        hdr = hdr->next; 
    651651    } 
     
    11721172            while (chdr != &regc->contact_hdr_list) { 
    11731173                pj_list_insert_before(ins_hdr, (pjsip_hdr*) 
    1174                     pjsip_hdr_shallow_clone(tsx->last_tx->pool, chdr)); 
     1174                    pjsip_hdr_clone(tsx->last_tx->pool, chdr)); 
    11751175                chdr = chdr->next; 
    11761176            } 
Note: See TracChangeset for help on using the changeset viewer.