diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 942d106dd9..8be73813e5 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -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;