Changeset 2745 for pjproject


Ignore:
Timestamp:
Jun 4, 2009 3:51:39 PM (15 years ago)
Author:
bennylp
Message:

Ticket #863: Account may always re-register with IPv6, due to string comparison of IPv6 address. Note: this needs ticket #878)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c

    r2737 r2745  
    569569    pjsip_sip_uri *uri; 
    570570    pjsip_via_hdr *via; 
     571    pj_sockaddr contact_addr; 
     572    pj_sockaddr recv_addr; 
     573    pj_status_t status; 
     574    pj_bool_t matched; 
    571575    pj_str_t srv_ip; 
    572576 
     
    627631    } 
    628632 
    629     if (uri->port == rport && 
    630         pj_stricmp(&uri->host, via_addr)==0) 
    631     { 
     633    /* Convert IP address strings into sockaddr for comparison. 
     634     * (http://trac.pjsip.org/repos/ticket/863) 
     635     */ 
     636    status = pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &uri->host,  
     637                               &contact_addr); 
     638    if (status == PJ_SUCCESS) 
     639        status = pj_sockaddr_parse(pj_AF_UNSPEC(), 0, via_addr,  
     640                                   &recv_addr); 
     641    if (status == PJ_SUCCESS) { 
     642        /* Compare the addresses as sockaddr according to the ticket above */ 
     643        matched = (uri->port == rport && 
     644                   pj_sockaddr_cmp(&contact_addr, &recv_addr)==0); 
     645    } else { 
     646        /* Compare the addresses as string, as before */ 
     647        matched = (uri->port == rport && 
     648                   pj_stricmp(&uri->host, via_addr)==0); 
     649    } 
     650 
     651    if (matched) { 
    632652        /* Address doesn't change */ 
    633653        pj_pool_release(pool); 
Note: See TracChangeset for help on using the changeset viewer.