forked from Mirrors/freeswitch
Fix handling of the ZRTP cache path and file name
libzrtp strings are weird, and we were previously misusing the function zrtp_zstrcpyc. We can't use ZSTR_GV because it does insane things and causes an array-bounds warning on gcc 4.7. So we have to take matters into our own hands and setup the string correctly and copy data into it. Because we were doing it wrong, people would get weird pseudo-random single-character names for the zrtp cache file, and the file would end up in the wrong place. Now that this is fixed, users will need to locate and move their zrtp cache file to their db_dir and name it "zrtp.dat" if they wish to keep their current ZRTP cache. FS-4344 --resolve
This commit is contained in:
parent
283eb6ee45
commit
69cda3d7cc
@ -944,14 +944,16 @@ SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool)
|
||||
switch_core_hash_init(&alloc_hash, pool);
|
||||
#ifdef ENABLE_ZRTP
|
||||
if (zrtp_on) {
|
||||
uint32_t cache_len;
|
||||
zrtp_config_defaults(&zrtp_config);
|
||||
strcpy(zrtp_config.client_id, "FreeSWITCH");
|
||||
zrtp_config.is_mitm = 1;
|
||||
zrtp_config.lic_mode = ZRTP_LICENSE_MODE_ACTIVE;
|
||||
switch_snprintf(zrtp_cache_path, sizeof(zrtp_cache_path), "%s%szrtp.dat", SWITCH_GLOBAL_dirs.db_dir, SWITCH_PATH_SEPARATOR);
|
||||
zrtp_zstrcpyc((zrtp_stringn_t*)zrtp_config.def_cache_path.buffer, zrtp_cache_path);
|
||||
zrtp_config.def_cache_path.length = (uint16_t)strlen(zrtp_cache_path);
|
||||
zrtp_config.def_cache_path.max_length = 255;
|
||||
cache_len=(uint32_t)strlen(zrtp_cache_path);
|
||||
ZSTR_SET_EMPTY(zrtp_config.def_cache_path);
|
||||
zrtp_config.def_cache_path.length = cache_len > zrtp_config.def_cache_path.max_length ? zrtp_config.def_cache_path.max_length : (uint16_t)cache_len;
|
||||
strncpy(zrtp_config.def_cache_path.buffer, zrtp_cache_path, zrtp_config.def_cache_path.max_length);
|
||||
zrtp_config.cb.event_cb.on_zrtp_protocol_event = (void (*)(zrtp_stream_t*,zrtp_protocol_event_t))zrtp_event_callback;
|
||||
zrtp_config.cb.misc_cb.on_send_packet = zrtp_send_rtp_callback;
|
||||
zrtp_config.cb.event_cb.on_zrtp_security_event = (void (*)(zrtp_stream_t*,zrtp_security_event_t))zrtp_event_callback;
|
||||
|
Loading…
Reference in New Issue
Block a user