Ignore:
Timestamp:
Sep 3, 2018 7:13:40 AM (6 years ago)
Author:
ming
Message:

Re #2100: Fixed duplication of crypto names and keys to use pj_strdup(). Otherwise, when the account/global config's input strings are modified (or deallocated) after being passed to PJSIP, then the crypto name matching will fail and we will generate error: PJMEDIA_SRTP_ENOTSUPCRYPTO

File:
1 edited

Legend:

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

    r5856 r5872  
    144144        pj_strdup_with_null(pool, &dst->stun_srv[i], &src->stun_srv[i]); 
    145145    } 
     146 
     147    pjsua_srtp_opt_dup(pool, &dst->srtp_opt, &src->srtp_opt, PJ_FALSE); 
    146148} 
    147149 
     
    261263{ 
    262264    pj_bzero(cfg, sizeof(*cfg)); 
     265} 
     266 
     267 
     268PJ_DEF(void) pjsua_srtp_opt_dup( pj_pool_t *pool, pjsua_srtp_opt *dst, 
     269                                 const pjsua_srtp_opt *src, 
     270                                 pj_bool_t check_str) 
     271{ 
     272    pj_memcpy(dst, src, sizeof(*src)); 
     273    if (pool) { 
     274        unsigned i; 
     275         
     276        for (i = 0; i < src->crypto_count; i++) { 
     277            if (!check_str || 
     278                pj_stricmp(&dst->crypto[i].key, &src->crypto[i].key)) 
     279            { 
     280                pj_strdup(pool, &dst->crypto[i].key, &src->crypto[i].key); 
     281            } 
     282            if (!check_str || 
     283                pj_stricmp(&dst->crypto[i].name, &src->crypto[i].name)) 
     284            { 
     285                pj_strdup(pool, &dst->crypto[i].name, &src->crypto[i].name); 
     286            } 
     287        } 
     288    } 
    263289} 
    264290 
Note: See TracChangeset for help on using the changeset viewer.