mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 22:54:18 +00:00
fix possible bad pointer in global vars (please test)
This commit is contained in:
1 parent
89c5f3bf82
commit
4ae8282e6c
26 files changed
+185
-100
No files matched your search
@@ -349,7 +349,7 @@ SWITCH_STANDARD_API(timer_test_function)
|
||||
|
||||
SWITCH_STANDARD_API(group_call_function)
|
||||
{
|
||||
char *domain;
|
||||
char *domain, *dup_domain = NULL;
|
||||
char *group_name = NULL;
|
||||
char *flags;
|
||||
int ok = 0;
|
||||
@@ -392,7 +392,9 @@ SWITCH_STANDARD_API(group_call_function)
|
||||
if (domain) {
|
||||
*domain++ = '\0';
|
||||
} else {
|
||||
domain = switch_core_get_variable("domain");
|
||||
if ((dup_domain = switch_core_get_variable_dup("domain"))) {
|
||||
domain = dup_domain;
|
||||
}
|
||||
}
|
||||
|
||||
if (!zstr(domain)) {
|
||||
@@ -544,13 +546,14 @@ SWITCH_STANDARD_API(group_call_function)
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
|
||||
switch_safe_free(group_name);
|
||||
switch_safe_free(dup_domain);
|
||||
|
||||
if (!ok) {
|
||||
stream->write_function(stream, "error/NO_ROUTE_DESTINATION");
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -559,7 +562,7 @@ SWITCH_STANDARD_API(in_group_function)
|
||||
{
|
||||
switch_xml_t x_domain, xml = NULL, x_user = NULL, x_group;
|
||||
int argc;
|
||||
char *mydata = NULL, *argv[2], *user, *domain;
|
||||
char *mydata = NULL, *argv[2], *user, *domain, *dup_domain = NULL;
|
||||
char delim = ',';
|
||||
switch_event_t *params = NULL;
|
||||
const char *rval = "false";
|
||||
@@ -579,7 +582,9 @@ SWITCH_STANDARD_API(in_group_function)
|
||||
if ((domain = strchr(user, '@'))) {
|
||||
*domain++ = '\0';
|
||||
} else {
|
||||
domain = switch_core_get_variable("domain");
|
||||
if ((dup_domain = switch_core_get_variable_dup("domain"))) {
|
||||
domain = dup_domain;
|
||||
}
|
||||
}
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
@@ -601,6 +606,7 @@ SWITCH_STANDARD_API(in_group_function)
|
||||
|
||||
switch_xml_free(xml);
|
||||
switch_safe_free(mydata);
|
||||
switch_safe_free(dup_domain);
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -610,7 +616,7 @@ SWITCH_STANDARD_API(user_data_function)
|
||||
{
|
||||
switch_xml_t x_domain, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
|
||||
int argc;
|
||||
char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain;
|
||||
char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain, *dup_domain = NULL;
|
||||
char delim = ' ';
|
||||
const char *container = "params", *elem = "param";
|
||||
const char *result = NULL;
|
||||
@@ -631,7 +637,9 @@ SWITCH_STANDARD_API(user_data_function)
|
||||
if ((domain = strchr(user, '@'))) {
|
||||
*domain++ = '\0';
|
||||
} else {
|
||||
if (!(domain = switch_core_get_variable("domain"))) {
|
||||
if ((dup_domain = switch_core_get_variable("domain"))) {
|
||||
domain = dup_domain;
|
||||
} else {
|
||||
domain = "cluecon.com";
|
||||
}
|
||||
}
|
||||
@@ -694,6 +702,7 @@ SWITCH_STANDARD_API(user_data_function)
|
||||
}
|
||||
switch_xml_free(xml);
|
||||
switch_safe_free(mydata);
|
||||
switch_safe_free(dup_domain);
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -4375,7 +4384,9 @@ SWITCH_STANDARD_API(global_getvar_function)
|
||||
if (zstr(cmd)) {
|
||||
switch_core_dump_variables(stream);
|
||||
} else {
|
||||
stream->write_function(stream, "%s", switch_str_nil(switch_core_get_variable(cmd)));
|
||||
char *var = switch_core_get_variable_dup(cmd);
|
||||
stream->write_function(stream, "%s", switch_str_nil(var));
|
||||
switch_safe_free(var);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -2787,7 +2787,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session
|
||||
if ((domain = strchr(group, '@'))) {
|
||||
*domain++ = '\0';
|
||||
} else {
|
||||
domain = switch_core_get_variable("domain");
|
||||
domain = switch_core_get_variable_pdup("domain", switch_core_session_get_pool(session));
|
||||
}
|
||||
|
||||
if (!domain) {
|
||||
@@ -2908,7 +2908,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
|
||||
if ((domain = strchr(user, '@'))) {
|
||||
*domain++ = '\0';
|
||||
} else {
|
||||
domain = switch_core_get_variable("domain");
|
||||
domain = switch_core_get_variable_pdup("domain", switch_core_session_get_pool(session));
|
||||
}
|
||||
|
||||
if (!domain) {
|
||||
@@ -3193,10 +3193,11 @@ static switch_status_t event_chat_send(const char *proto, const char *from, cons
|
||||
if (body)
|
||||
switch_event_add_body(event, "%s", body);
|
||||
if (to) {
|
||||
const char *v;
|
||||
char *v;
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "To", to);
|
||||
if ((v = switch_core_get_variable(to))) {
|
||||
if ((v = switch_core_get_variable_dup(to))) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Command", v);
|
||||
free(v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3214,15 +3215,15 @@ static switch_status_t api_chat_send(const char *proto, const char *from, const
|
||||
const char *body, const char *type, const char *hint)
|
||||
{
|
||||
if (to) {
|
||||
const char *v;
|
||||
char *v = NULL;
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
char *cmd = NULL, *arg;
|
||||
|
||||
if (!(v = switch_core_get_variable(to))) {
|
||||
v = to;
|
||||
if (!(v = switch_core_get_variable_dup(to))) {
|
||||
v = strdup(to);
|
||||
}
|
||||
|
||||
cmd = strdup(v);
|
||||
cmd = v;
|
||||
switch_assert(cmd);
|
||||
|
||||
switch_url_decode(cmd);
|
||||
|
||||
@@ -89,7 +89,7 @@ SWITCH_LIMIT_INCR(limit_incr_redis)
|
||||
}
|
||||
|
||||
/* Get the keys for redis server */
|
||||
uuid_rediskey = switch_core_session_sprintf(session,"%s_%s_%s", switch_core_get_variable("hostname"), realm, resource);
|
||||
uuid_rediskey = switch_core_session_sprintf(session,"%s_%s_%s", switch_core_get_hostname(), realm, resource);
|
||||
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
|
||||
|
||||
if ((pvt = switch_channel_get_private(channel, "limit_redis"))) {
|
||||
@@ -179,7 +179,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", (char *)p_key);
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
p_uuid_key = switch_core_session_sprintf(session, "%s_%s", switch_core_get_variable("hostname"), (char *)p_key);
|
||||
p_uuid_key = switch_core_session_sprintf(session, "%s_%s", switch_core_get_hostname(), (char *)p_key);
|
||||
if (credis_decr(redis,p_uuid_key,&uuid_val) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", p_uuid_key);
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
@@ -193,7 +193,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
|
||||
} else {
|
||||
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
|
||||
uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_variable("hostname"), realm, resource);
|
||||
uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_hostname(), realm, resource);
|
||||
switch_core_hash_delete(pvt->hash, (const char *) rediskey);
|
||||
|
||||
if (credis_decr(redis, rediskey, &val) != 0) {
|
||||
@@ -249,13 +249,13 @@ SWITCH_LIMIT_RESET(limit_reset_redis)
|
||||
{
|
||||
REDIS redis;
|
||||
if (redis_factory(&redis) == SWITCH_STATUS_SUCCESS) {
|
||||
char *rediskey = switch_mprintf("%s_*", switch_core_get_variable("hostname"));
|
||||
char *rediskey = switch_mprintf("%s_*", switch_core_get_hostname());
|
||||
int dec = 0, val = 0, keyc;
|
||||
char *uuids[2000];
|
||||
|
||||
if ((keyc = credis_keys(redis, rediskey, uuids, switch_arraylen(uuids))) > 0) {
|
||||
int i = 0;
|
||||
int hostnamelen = strlen(switch_core_get_variable("hostname"))+1;
|
||||
int hostnamelen = strlen(switch_core_get_hostname())+1;
|
||||
|
||||
for (i = 0; i < keyc && uuids[i]; i++){
|
||||
const char *key = uuids[i] + hostnamelen;
|
||||
|
||||
@@ -2734,6 +2734,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
char *forwarded_by = NULL;
|
||||
char *read_flags = NORMAL_FLAG_STRING;
|
||||
char *dup_domain = NULL;
|
||||
|
||||
if (zstr(data)) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
@@ -2781,7 +2782,9 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
|
||||
}
|
||||
|
||||
if (zstr(domain)) {
|
||||
domain = switch_core_get_variable("domain");
|
||||
if ((dup_domain = switch_core_get_variable_dup("domain"))) {
|
||||
domain = dup_domain;
|
||||
}
|
||||
profile_name = domain;
|
||||
}
|
||||
|
||||
@@ -2915,6 +2918,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
|
||||
end:
|
||||
|
||||
switch_safe_free(dup);
|
||||
switch_safe_free(dup_domain);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,
|
||||
if (session) {
|
||||
profile = switch_channel_get_variable(switch_core_session_get_channel(session), "sip_profile");
|
||||
} else {
|
||||
profile = switch_core_get_variable("sip_profile");
|
||||
profile = switch_core_get_variable_pdup("sip_profile", switch_core_session_get_pool(session));
|
||||
}
|
||||
if (zstr(profile)) {
|
||||
profile = "default";
|
||||
|
||||
@@ -2049,7 +2049,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
|
||||
} else if (!strcasecmp(var, "ext-rtp-ip")) {
|
||||
char *ip = globals.guess_ip;
|
||||
if (val && !strcasecmp(val, "auto-nat")) {
|
||||
ip = globals.auto_nat ? switch_core_get_variable("nat_public_addr") : globals.guess_ip;
|
||||
ip = globals.auto_nat ? switch_core_get_variable_pdup("nat_public_addr", module_pool) : globals.guess_ip;
|
||||
} else if (val && !strcasecmp(val, "auto")) {
|
||||
globals.auto_nat = 0;
|
||||
ip = globals.guess_ip;
|
||||
@@ -2523,7 +2523,7 @@ static switch_status_t load_config(void)
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
globals.running = 1;
|
||||
globals.auto_nat = (switch_core_get_variable("nat_type") ? 1 : 0);
|
||||
globals.auto_nat = (switch_nat_get_type() ? 1 : 0);
|
||||
|
||||
switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), NULL, AF_INET);
|
||||
|
||||
|
||||
@@ -1625,9 +1625,10 @@ bool Board::KhompPvt::setCollectCall()
|
||||
DBG(FUNC, PVT_FMT(_target, "option drop collect call is '%s'") % (Opt::_options._drop_collect_call() ? "yes" : "no"));
|
||||
|
||||
// get global filter configuration value
|
||||
tmp_var = switch_core_get_variable("KDropCollectCall");
|
||||
tmp_var = switch_core_get_variable_dup("KDropCollectCall");
|
||||
confvalues.push_back(getTriStateValue(tmp_var));
|
||||
DBG(FUNC, PVT_FMT(_target, "global KDropCollectCall was '%s'") % (tmp_var ? tmp_var : "(empty)"));
|
||||
switch_safe_free(tmp_var);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -3501,7 +3501,7 @@ SWITCH_STANDARD_API(sofia_contact_function)
|
||||
}
|
||||
|
||||
if (zstr(domain)) {
|
||||
domain = switch_core_get_variable("domain");
|
||||
domain = switch_core_get_variable_pdup("domain", switch_core_session_get_pool(session));
|
||||
}
|
||||
|
||||
if (!user) goto end;
|
||||
@@ -4776,7 +4776,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
||||
mod_sofia_globals.running = 1;
|
||||
switch_mutex_unlock(mod_sofia_globals.mutex);
|
||||
|
||||
mod_sofia_globals.auto_nat = (switch_core_get_variable("nat_type") ? 1 : 0);
|
||||
mod_sofia_globals.auto_nat = (switch_nat_get_type() ? 1 : 0);
|
||||
|
||||
switch_queue_create(&mod_sofia_globals.presence_queue, SOFIA_QUEUE_SIZE, mod_sofia_globals.pool);
|
||||
switch_queue_create(&mod_sofia_globals.mwi_queue, SOFIA_QUEUE_SIZE, mod_sofia_globals.pool);
|
||||
|
||||
@@ -1459,7 +1459,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
|
||||
supported = switch_core_sprintf(profile->pool, "%s%sprecondition, path, replaces", use_100rel ? "100rel, " : "", use_timer ? "timer, " : "");
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && switch_core_get_variable("nat_type")) {
|
||||
if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && switch_nat_get_type()) {
|
||||
if (switch_nat_add_mapping(profile->sip_port, SWITCH_NAT_UDP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created UDP nat mapping for %s port %d\n", profile->name, profile->sip_port);
|
||||
}
|
||||
@@ -1676,7 +1676,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
switch_event_fire(&s_event);
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && switch_core_get_variable("nat_type")) {
|
||||
if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && switch_nat_get_type()) {
|
||||
if (switch_nat_del_mapping(profile->sip_port, SWITCH_NAT_UDP) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deleted UDP nat mapping for %s port %d\n", profile->name, profile->sip_port);
|
||||
}
|
||||
@@ -3741,9 +3741,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
if (!profile->rtpip[0]) {
|
||||
profile->rtpip[profile->rtpip_index++] = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
|
||||
}
|
||||
|
||||
if (switch_core_get_variable("nat_type")) {
|
||||
const char *ip = switch_core_get_variable("nat_public_addr");
|
||||
|
||||
if (switch_nat_get_type()) {
|
||||
char *ip = switch_core_get_variable_dup("nat_public_addr");
|
||||
if (ip && !strchr(profile->sipip, ':')) {
|
||||
if (!profile->extrtpip) {
|
||||
profile->extrtpip = switch_core_strdup(profile->pool, ip);
|
||||
@@ -3754,6 +3754,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
sofia_set_pflag(profile, PFLAG_AUTO_NAT);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "NAT detected setting external ip to %s\n", ip);
|
||||
}
|
||||
switch_safe_free(ip);
|
||||
}
|
||||
|
||||
if (profile->nonce_ttl < 60) {
|
||||
|
||||
@@ -2642,7 +2642,7 @@ static int config(void)
|
||||
} else if (!strcmp(var, "debug")) {
|
||||
globals.debug = atoi(val);
|
||||
} else if (!strcmp(var, "nat-map")) {
|
||||
if (switch_true(val) && switch_core_get_variable("nat_type")) {
|
||||
if (switch_true(val) && switch_nat_get_type()) {
|
||||
prefs.nat_map = 1;
|
||||
}
|
||||
} else if (!strcmp(var, "listen-port")) {
|
||||
@@ -2795,7 +2795,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
|
||||
|
||||
close_socket(&listen_list.sock);
|
||||
|
||||
if (prefs.nat_map && switch_core_get_variable("nat_type")) {
|
||||
if (prefs.nat_map && switch_nat_get_type()) {
|
||||
switch_nat_del_mapping(prefs.port, SWITCH_NAT_TCP);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ static int next_file(switch_file_handle_t *handle)
|
||||
|
||||
|
||||
if (!prefix) {
|
||||
if (!(prefix = switch_core_get_variable("sound_prefix"))) {
|
||||
if (!(prefix = switch_core_get_variable_pdup("sound_prefix", handle->memory_pool))) {
|
||||
prefix = SWITCH_GLOBAL_dirs.sounds_dir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3378,8 +3378,9 @@ static JSBool js_global_get(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
||||
|
||||
if (argc > 0) {
|
||||
var_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
|
||||
val = switch_core_get_variable(var_name);
|
||||
val = switch_core_get_variable_dup(var_name);
|
||||
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, val));
|
||||
free(val);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -322,6 +322,7 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)
|
||||
int at = 0;
|
||||
char *dp;
|
||||
abyss_bool rval = FALSE;
|
||||
char *dup_domain = NULL;
|
||||
|
||||
p = RequestHeaderValue(r, "authorization");
|
||||
|
||||
@@ -354,7 +355,9 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)
|
||||
if (globals.default_domain) {
|
||||
domain_name = globals.default_domain;
|
||||
} else {
|
||||
domain_name = switch_core_get_variable("domain");
|
||||
if ((dup_domain = switch_core_get_variable_dup("domain"))) {
|
||||
domain_name = dup_domain;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,6 +468,7 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)
|
||||
switch_safe_free(mypass1);
|
||||
switch_safe_free(mypass2);
|
||||
switch_safe_free(box);
|
||||
switch_safe_free(dup_domain);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user