FS-9652: improve sql sanitization

This commit is contained in:
Mike Jerris committed 2016-11-11 11:27:35 -06:00
1 parent 53dbe5d84a
commit e1b3ee1efd
20 files changed
+148 -145

No files matched your search

+9 -9
View File
@@ -285,7 +285,7 @@ char * skinny_profile_find_session_uuid(skinny_profile_t *profile, listener_t *l
helper.channel_uuid = NULL;
if(listener) {
device_condition = switch_mprintf("device_name='%s' AND device_instance=%d",
device_condition = switch_mprintf("device_name='%q' AND device_instance=%d",
listener->device_name, listener->device_instance);
} else {
device_condition = switch_mprintf("1=1");
@@ -496,7 +496,7 @@ uint32_t skinny_line_get_state(listener_t *listener, uint32_t line_instance, uin
helper.call_state = -1;
if ((sql = switch_mprintf(
"SELECT call_state FROM skinny_active_lines "
"WHERE device_name='%s' AND device_instance=%d "
"WHERE device_name='%q' AND device_instance=%d "
"AND %s AND %s "
"ORDER BY call_state, channel_uuid", /* off hook first */
listener->device_name, listener->device_instance,
@@ -532,7 +532,7 @@ uint32_t skinny_line_count_active(listener_t *listener)
helper.count = 0;
if ((sql = switch_mprintf(
"SELECT call_state FROM skinny_active_lines "
"WHERE device_name='%s' AND device_instance=%d "
"WHERE device_name='%q' AND device_instance=%d "
"AND call_state not in (%d,%d,%d)",
listener->device_name, listener->device_instance,
SKINNY_ON_HOOK, SKINNY_IN_USE_REMOTELY, SKINNY_HOLD
@@ -987,7 +987,7 @@ switch_status_t skinny_ring_active_calls(listener_t *listener)
"ON skinny_active_lines.device_name = skinny_lines.device_name "
"AND skinny_active_lines.device_instance = skinny_lines.device_instance "
"AND skinny_active_lines.line_instance = skinny_lines.line_instance "
"WHERE skinny_lines.device_name='%s' AND skinny_lines.device_instance=%d "
"WHERE skinny_lines.device_name='%q' AND skinny_lines.device_instance=%d "
"AND (call_state=%d)",
listener->device_name, listener->device_instance, SKINNY_RING_IN))) {
skinny_execute_sql_callback(listener->profile, listener->profile->sql_mutex, sql, skinny_ring_active_calls_callback, &helper);
@@ -1370,9 +1370,9 @@ switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, swi
if ((sql = switch_mprintf(
"INSERT INTO skinny_active_lines "
"(device_name, device_instance, line_instance, channel_uuid, call_id, call_state) "
"SELECT device_name, device_instance, line_instance, '%s', %d, %d "
"SELECT device_name, device_instance, line_instance, '%q', %d, %d "
"FROM skinny_lines "
"WHERE value='%s'",
"WHERE value='%q'",
switch_core_session_get_uuid(nsession), tech_pvt->call_id, SKINNY_ON_HOOK, dest
))) {
skinny_execute_sql(profile, sql, profile->sql_mutex);
@@ -1731,7 +1731,7 @@ static void flush_listener(listener_t *listener)
if ((sql = switch_mprintf(
"SELECT '%q', value, '%q', '%q', '%d' "
"FROM skinny_lines "
"WHERE device_name='%s' AND device_instance=%d "
"WHERE device_name='%q' AND device_instance=%d "
"ORDER BY position",
profile->name, profile->domain, listener->device_name, listener->device_instance,
listener->device_name, listener->device_instance
@@ -1796,7 +1796,7 @@ switch_status_t dump_device(skinny_profile_t *profile, const char *device_name,
{
char *sql;
if ((sql = switch_mprintf("SELECT name, user_id, instance, ip, type, max_streams, port, codec_string, headset, handset, speaker "
"FROM skinny_devices WHERE name='%s'",
"FROM skinny_devices WHERE name='%q'",
device_name))) {
skinny_execute_sql_callback(profile, profile->sql_mutex, sql, dump_device_callback, stream);
switch_safe_free(sql);
@@ -2657,7 +2657,7 @@ static void skinny_message_waiting_event_handler(switch_event_t *event)
if ((sql = switch_mprintf(
"SELECT device_name, device_instance FROM skinny_lines "
"WHERE value='%s' AND line_instance=1", user))) {
"WHERE value='%q' AND line_instance=1", user))) {
struct skinny_message_waiting_event_handler_helper helper = {0};
helper.profile = profile;
helper.yn = switch_true(yn);
@@ -237,9 +237,9 @@ switch_status_t skinny_device_event(listener_t *listener, switch_event_t **ev, s
switch_event_create_subclass(&event, event_id, subclass_name);
switch_assert(event);
if ((sql = switch_mprintf("SELECT '%s', name, user_id, instance, ip, type, max_streams, port, codec_string "
if ((sql = switch_mprintf("SELECT '%q', name, user_id, instance, ip, type, max_streams, port, codec_string "
"FROM skinny_devices "
"WHERE name='%s' AND instance=%d",
"WHERE name='%q' AND instance=%d",
listener->profile->name,
listener->device_name, listener->device_instance))) {
skinny_execute_sql_callback(profile, profile->sql_mutex, sql, skinny_device_event_callback, event);
@@ -263,7 +263,7 @@ switch_status_t skinny_session_walk_lines(skinny_profile_t *profile, char *chann
"ON skinny_active_lines.device_name = skinny_lines.device_name "
"AND skinny_active_lines.device_instance = skinny_lines.device_instance "
"AND skinny_active_lines.line_instance = skinny_lines.line_instance "
"WHERE channel_uuid='%s'",
"WHERE channel_uuid='%q'",
channel_uuid))) {
skinny_execute_sql_callback(profile, profile->sql_mutex, sql, callback, data);
switch_safe_free(sql);
@@ -325,7 +325,7 @@ void skinny_line_get(listener_t *listener, uint32_t instance, struct line_stat_r
if ((sql = switch_mprintf(
"SELECT '%d' AS wanted_position, position, label, value, caller_name "
"FROM skinny_lines "
"WHERE device_name='%s' AND device_instance=%d "
"WHERE device_name='%q' AND device_instance=%d "
"ORDER BY position",
instance,
listener->device_name, listener->device_instance
@@ -368,7 +368,7 @@ void skinny_speed_dial_get(listener_t *listener, uint32_t instance, struct speed
if ((sql = switch_mprintf(
"SELECT '%d' AS wanted_position, position, label, value, settings "
"FROM skinny_buttons "
"WHERE device_name='%s' AND device_instance=%d AND type=%d "
"WHERE device_name='%q' AND device_instance=%d AND type=%d "
"ORDER BY position",
instance,
listener->device_name, listener->device_instance,
@@ -412,7 +412,7 @@ void skinny_service_url_get(listener_t *listener, uint32_t instance, struct serv
if ((sql = switch_mprintf(
"SELECT '%d' AS wanted_position, position, label, value, settings "
"FROM skinny_buttons "
"WHERE device_name='%s' AND device_instance=%d AND type=%d "
"WHERE device_name='%q' AND device_instance=%d AND type=%d "
"ORDER BY position",
instance,
listener->device_name,
@@ -458,7 +458,7 @@ void skinny_feature_get(listener_t *listener, uint32_t instance, struct feature_
if ((sql = switch_mprintf(
"SELECT '%d' AS wanted_position, position, label, value, settings "
"FROM skinny_buttons "
"WHERE device_name='%s' AND device_instance=%d AND NOT (type=%d OR type=%d) "
"WHERE device_name='%q' AND device_instance=%d AND NOT (type=%d OR type=%d) "
"ORDER BY position",
instance,
listener->device_name,
+8 -8
View File
@@ -1070,7 +1070,7 @@ switch_status_t skinny_hold_active_calls(listener_t *listener)
"ON skinny_active_lines.device_name = skinny_lines.device_name "
"AND skinny_active_lines.device_instance = skinny_lines.device_instance "
"AND skinny_active_lines.line_instance = skinny_lines.line_instance "
"WHERE skinny_lines.device_name='%s' AND skinny_lines.device_instance=%d AND (call_state=%d OR call_state=%d)",
"WHERE skinny_lines.device_name='%q' AND skinny_lines.device_instance=%d AND (call_state=%d OR call_state=%d)",
listener->device_name, listener->device_instance, SKINNY_PROCEED, SKINNY_CONNECTED))) {
skinny_execute_sql_callback(listener->profile, listener->profile->sql_mutex, sql, skinny_hold_active_calls_callback, &helper);
switch_safe_free(sql);
@@ -1673,7 +1673,7 @@ switch_status_t skinny_handle_on_hook_message(listener_t *listener, skinny_messa
"ON skinny_active_lines.device_name = skinny_lines.device_name "
"AND skinny_active_lines.device_instance = skinny_lines.device_instance "
"AND skinny_active_lines.line_instance = skinny_lines.line_instance "
"WHERE skinny_lines.device_name='%s' AND skinny_lines.device_instance=%d",
"WHERE skinny_lines.device_name='%q' AND skinny_lines.device_instance=%d",
listener->device_name, listener->device_instance)))
{
skinny_execute_sql_callback(listener->profile, listener->profile->sql_mutex, sql, skinny_hangup_active_calls_callback, &helper);
@@ -1778,9 +1778,9 @@ switch_status_t skinny_handle_config_stat_request(listener_t *listener, skinny_m
if ((sql = switch_mprintf(
"SELECT name, user_id, instance, '' AS user_name, '' AS server_name, "
"(SELECT COUNT(*) FROM skinny_lines WHERE device_name='%s' AND device_instance=%d) AS number_lines, "
"(SELECT COUNT(*) FROM skinny_buttons WHERE device_name='%s' AND device_instance=%d AND type=%d) AS number_speed_dials "
"FROM skinny_devices WHERE name='%s' ",
"(SELECT COUNT(*) FROM skinny_lines WHERE device_name='%q' AND device_instance=%d) AS number_lines, "
"(SELECT COUNT(*) FROM skinny_buttons WHERE device_name='%q' AND device_instance=%d AND type=%d) AS number_speed_dials "
"FROM skinny_devices WHERE name='%q' ",
listener->device_name,
listener->device_instance,
listener->device_name,
@@ -1854,7 +1854,7 @@ switch_status_t skinny_handle_button_template_request(listener_t *listener, skin
if ((sql = switch_mprintf(
"SELECT device_name, device_instance, position, type "
"FROM skinny_buttons "
"WHERE device_name='%s' AND device_instance=%d "
"WHERE device_name='%q' AND device_instance=%d "
"ORDER BY position",
listener->device_name, listener->device_instance
))) {
@@ -1866,7 +1866,7 @@ switch_status_t skinny_handle_button_template_request(listener_t *listener, skin
if ((sql = switch_mprintf(
"SELECT device_name, device_instance, position, %d AS type "
"FROM skinny_lines "
"WHERE device_name='%s' AND device_instance=%d "
"WHERE device_name='%q' AND device_instance=%d "
"ORDER BY position",
SKINNY_BUTTON_LINE,
listener->device_name, listener->device_instance
@@ -1979,7 +1979,7 @@ switch_status_t skinny_handle_capabilities_response(listener_t *listener, skinny
}
codec_string[string_len] = '\0';
if ((sql = switch_mprintf(
"UPDATE skinny_devices SET codec_string='%q' WHERE name='%s'",
"UPDATE skinny_devices SET codec_string='%q' WHERE name='%q'",
codec_string,
listener->device_name
))) {
+5 -5
View File
@@ -1404,7 +1404,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (presence_id || presence_data) {
char *sql = switch_mprintf("update sip_dialogs set presence_id='%q',presence_data='%q' "
"where uuid='%s';\n", switch_str_nil(presence_id), switch_str_nil(presence_data),
"where uuid='%q';\n", switch_str_nil(presence_id), switch_str_nil(presence_data),
switch_core_session_get_uuid(session));
switch_assert(sql);
sofia_glue_execute_sql_now(tech_pvt->profile, &sql, SWITCH_TRUE);
@@ -3802,7 +3802,7 @@ static void select_from_profile(sofia_profile_t *profile,
"from sip_registrations where profile_name='%q' "
"and upper(sip_user)=upper('%q') "
"and (sip_host='%q' or presence_hosts like '%%%q%%') "
"and contact not like '%%%s%%'", (concat != NULL) ? concat : "", profile->name, user, domain, domain, exclude_contact);
"and contact not like '%%%q%%'", (concat != NULL) ? concat : "", profile->name, user, domain, domain, exclude_contact);
} else {
sql = switch_mprintf("select contact, profile_name, '%q' "
"from sip_registrations where profile_name='%q' "
@@ -5282,12 +5282,12 @@ void general_event_handler(switch_event_t *event)
} else {
if (!strcasecmp(es, "message-summary")) {
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
"from sip_registrations where mwi_user='%s' and mwi_host='%q'",
"from sip_registrations where mwi_user='%q' and mwi_host='%q'",
ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
);
} else {
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
"from sip_registrations where sip_user='%s' and sip_host='%q'",
"from sip_registrations where sip_user='%q' and sip_host='%q'",
ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
);
@@ -5389,7 +5389,7 @@ void general_event_handler(switch_event_t *event)
"from sip_subscriptions where event='as-feature-event' and call_id='%q'", stream.data, ct, call_id);
} else {
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,call_id,full_from,full_to,expires,'%q', '%q' "
"from sip_subscriptions where event='as-feature-event' and sip_user='%s' and sip_host='%q'", stream.data, ct, switch_str_nil(user), switch_str_nil(host)
"from sip_subscriptions where event='as-feature-event' and sip_user='%q' and sip_host='%q'", stream.data, ct, switch_str_nil(user), switch_str_nil(host)
);
}
+9 -9
View File
@@ -2782,10 +2782,10 @@ void event_handler(switch_event_t *event)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n");
} else {
if (!strcmp(ping_status, "REACHABLE")) {
sql = switch_mprintf("update sip_registrations set ping_status='%s' where sip_user='%s' and sip_host='%s' and call_id='%q'",
sql = switch_mprintf("update sip_registrations set ping_status='%q' where sip_user='%q' and sip_host='%q' and call_id='%q'",
"Reachable", from_user, from_host, call_id);
} else {
sql = switch_mprintf("update sip_registrations set ping_status='%s' where sip_user='%s' and sip_host='%s' and call_id='%q'",
sql = switch_mprintf("update sip_registrations set ping_status='%q' where sip_user='%q' and sip_host='%q' and call_id='%q'",
"Unreachable", from_user, from_host, call_id);
}
if (sql) {
@@ -6182,7 +6182,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
sip_user_status.status_len = sizeof(ping_status);
sip_user_status.contact = sip_contact;
sip_user_status.contact_len = sizeof(sip_contact);
sql = switch_mprintf("select ping_status, ping_count, contact from sip_registrations where sip_user='%s' and sip_host='%s' and call_id='%q'",
sql = switch_mprintf("select ping_status, ping_count, contact from sip_registrations where sip_user='%q' and sip_host='%q' and call_id='%q'",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id);
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_sip_user_status_callback, &sip_user_status);
switch_safe_free(sql);
@@ -6192,7 +6192,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
if (sip_user_status.count >= 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Ping to sip user '%s@%s' failed with code %d - count %d, state %s\n",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, status, sip_user_status.count, sip_user_status.status);
sql = switch_mprintf("update sip_registrations set ping_count=%d, ping_time=%d where sip_user='%s' and sip_host='%s' and call_id='%q'",
sql = switch_mprintf("update sip_registrations set ping_count=%d, ping_time=%d where sip_user='%q' and sip_host='%q' and call_id='%q'",
sip_user_status.count, ping_time, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
switch_safe_free(sql);
@@ -6201,7 +6201,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
if (strcmp(sip_user_status.status, "Unreachable")) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Sip user '%s@%s' is now Unreachable\n",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
sql = switch_mprintf("update sip_registrations set ping_status='Unreachable', ping_time=%d where sip_user='%s' and sip_host='%s' and call_id='%q'",
sql = switch_mprintf("update sip_registrations set ping_status='Unreachable', ping_time=%d where sip_user='%q' and sip_host='%q' and call_id='%q'",
ping_time, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
switch_safe_free(sql);
@@ -6213,7 +6213,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Expire sip user '%s@%s' due to options failure\n",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
sql = switch_mprintf("update sip_registrations set expires=%ld, ping_time=%d where sip_user='%s' and sip_host='%s' and call_id='%q'",
sql = switch_mprintf("update sip_registrations set expires=%ld, ping_time=%d where sip_user='%q' and sip_host='%q' and call_id='%q'",
(long) now, ping_time, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
switch_safe_free(sql);
@@ -6225,7 +6225,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
if (sip_user_status.count <= sip_user_ping_max) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Ping to sip user '%s@%s' succeeded with code %d - count %d, state %s\n",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, status, sip_user_status.count, sip_user_status.status);
sql = switch_mprintf("update sip_registrations set ping_count=%d, ping_time=%d where sip_user='%s' and sip_host='%s' and call_id='%q'",
sql = switch_mprintf("update sip_registrations set ping_count=%d, ping_time=%d where sip_user='%q' and sip_host='%q' and call_id='%q'",
sip_user_status.count, ping_time, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
switch_safe_free(sql);
@@ -6234,7 +6234,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
if (strcmp(sip_user_status.status, "Reachable")) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Sip user '%s@%s' is now Reachable\n",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
sql = switch_mprintf("update sip_registrations set ping_status='Reachable' where sip_user='%s' and sip_host='%s' and call_id='%q'",
sql = switch_mprintf("update sip_registrations set ping_status='Reachable' where sip_user='%q' and sip_host='%q' and call_id='%q'",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
switch_safe_free(sql);
@@ -6829,7 +6829,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
const char *presence_id = switch_channel_get_variable(channel, "presence_id");
sql = switch_mprintf("update sip_dialogs set state='%q',presence_id='%q',presence_data='%q' "
"where uuid='%s';\n", astate, switch_str_nil(presence_id), switch_str_nil(presence_data),
"where uuid='%q';\n", astate, switch_str_nil(presence_id), switch_str_nil(presence_data),
switch_core_session_get_uuid(session));
switch_assert(sql);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
+2 -2
View File
@@ -527,7 +527,7 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
char buf[512] = "";
switch_console_callback_match_t *matches;
sql = switch_mprintf("select profile_name from sip_registrations where hostname='%q' and (sip_host='%s' or mwi_host='%s')",
sql = switch_mprintf("select profile_name from sip_registrations where hostname='%q' and (sip_host='%q' or mwi_host='%q')",
mod_sofia_globals.hostname, host, host);
if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
@@ -3081,7 +3081,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
if (!zstr(astate) && !zstr(uuid) &&
helper && helper->stream.data && strcmp(helper->last_uuid, uuid) && strcasecmp(astate, "terminated") && strchr(uuid, '-')) {
helper->stream.write_function(&helper->stream, "update sip_dialogs set state='%s' where hostname='%q' and profile_name='%q' and uuid='%s';",
helper->stream.write_function(&helper->stream, "update sip_dialogs set state='%q' where hostname='%q' and profile_name='%q' and uuid='%q';",
astate, mod_sofia_globals.hostname, profile->name, uuid);
switch_copy_string(helper->last_uuid, uuid, sizeof(helper->last_uuid));
}
+9 -9
View File
@@ -817,7 +817,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
if (now) {
sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' "
"and profile_name='%s' and expires <= %ld", mod_sofia_globals.hostname, profile->name, (long) now);
"and profile_name='%q' and expires <= %ld", mod_sofia_globals.hostname, profile->name, (long) now);
sofia_glue_execute_sql_callback(profile, profile->dbh_mutex, sql, sofia_sla_dialog_del_callback, profile);
free(sql);
@@ -888,8 +888,8 @@ void sofia_reg_check_ping_expire(sofia_profile_t *profile, time_t now, int inter
if (sofia_test_pflag(profile, PFLAG_ALL_REG_OPTIONS_PING)) {
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,rpid,"
"expires,user_agent,server_user,server_host,profile_name "
"from sip_registrations where hostname='%s' and "
"profile_name='%s' and orig_hostname='%s' and "
"from sip_registrations where hostname='%q' and "
"profile_name='%q' and orig_hostname='%q' and "
"ping_expires > 0 and ping_expires <= %ld",
mod_sofia_globals.hostname, profile->name, mod_sofia_globals.hostname, (long) now);
@@ -899,7 +899,7 @@ void sofia_reg_check_ping_expire(sofia_profile_t *profile, time_t now, int inter
sql = switch_mprintf(" select call_id,sip_user,sip_host,contact,status,rpid, "
" expires,user_agent,server_user,server_host,profile_name "
" from sip_registrations where (status like '%%UDP-NAT%%' or force_ping=1)"
" and hostname='%s' and profile_name='%s' and ping_expires > 0 and ping_expires <= %ld ",
" and hostname='%q' and profile_name='%q' and ping_expires > 0 and ping_expires <= %ld ",
mod_sofia_globals.hostname, profile->name, (long) now);
sofia_glue_execute_sql_callback(profile, profile->dbh_mutex, sql, sofia_reg_nat_callback, profile);
@@ -908,8 +908,8 @@ void sofia_reg_check_ping_expire(sofia_profile_t *profile, time_t now, int inter
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,rpid,"
"expires,user_agent,server_user,server_host,profile_name "
"from sip_registrations where (status like '%%NAT%%' "
"or contact like '%%fs_nat=yes%%' or force_ping=1) and hostname='%s' "
"and profile_name='%s' and orig_hostname='%s' and "
"or contact like '%%fs_nat=yes%%' or force_ping=1) and hostname='%q' "
"and profile_name='%q' and orig_hostname='%q' and "
"ping_expires > 0 and ping_expires <= %ld",
mod_sofia_globals.hostname, profile->name, mod_sofia_globals.hostname, (long) now);
@@ -918,8 +918,8 @@ void sofia_reg_check_ping_expire(sofia_profile_t *profile, time_t now, int inter
} else {
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,rpid,"
"expires,user_agent,server_user,server_host,profile_name "
"from sip_registrations where force_ping=1 and hostname='%s' "
"and profile_name='%s' and orig_hostname='%s' and "
"from sip_registrations where force_ping=1 and hostname='%q' "
"and profile_name='%q' and orig_hostname='%q' and "
"ping_expires > 0 and ping_expires <= %ld",
mod_sofia_globals.hostname, profile->name, mod_sofia_globals.hostname, (long) now);
@@ -3230,7 +3230,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
if (nc && cnonce && qop) {
ncl = strtoul(nc, 0, 16);
sql = switch_mprintf("update sip_authentication set expires='%ld',last_nc=%lu where nonce='%s'",
sql = switch_mprintf("update sip_authentication set expires='%ld',last_nc=%lu where nonce='%q'",
(long)switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : DEFAULT_NONCE_TTL) + exptime, ncl, nonce);
switch_assert(sql != NULL);