summaryrefslogtreecommitdiff
path: root/res/res_pjsip
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2016-03-06 13:38:41 -0700
committerGeorge Joseph <george.joseph@fairview5.com>2016-03-07 13:16:41 -0600
commitd2eb65f71e9347c15d469579bbb20c47501d924b (patch)
tree7146e406d5ab4a30eebbf6b62161a9d219f98cca /res/res_pjsip
parentee5a9442a295eedf05b998ef1b5c101832d6673f (diff)
res_pjsip: Strip spaces from items parsed from comma-separated lists
Configurations like "aors = a, b, c" were either ignoring everything after "a" or trying to look up " b". Same for mailboxes, ciphers, contacts and a few others. To fix, all the strsep(&copy, ",") calls have been wrapped in ast_strip. To facilitate this, ast_strip, ast_skip_blanks and ast_skip_nonblanks were updated to handle null pointers. In some cases, an ast_strlen_zero() test was added to skip consecutive commas. There was also an attempt to ast_free an ast_strdupa'd string in ast_sip_for_each_aor which was causing a SEGV. I removed it. Although this issue was reported for realtime, the issue was in the res_pjsip modules so all config mechanisms were affected. ASTERISK-25829 #close Reported-by: Mateusz Kowalski Change-Id: I0b22a2cf22a7c1c50d4ecacbfa540155bec0e7a2
Diffstat (limited to 'res/res_pjsip')
-rw-r--r--res/res_pjsip/config_transport.c3
-rw-r--r--res/res_pjsip/location.c11
-rw-r--r--res/res_pjsip/pjsip_configuration.c8
-rw-r--r--res/res_pjsip/pjsip_options.c8
4 files changed, 18 insertions, 12 deletions
diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c
index 61a979c88..db579bf2f 100644
--- a/res/res_pjsip/config_transport.c
+++ b/res/res_pjsip/config_transport.c
@@ -985,8 +985,7 @@ static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast
}
parse = ast_strdupa(S_OR(var->value, ""));
- while ((name = strsep(&parse, ","))) {
- name = ast_strip(name);
+ while ((name = ast_strip(strsep(&parse, ",")))) {
if (ast_strlen_zero(name)) {
continue;
}
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index c070e7dbc..4008abad1 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -205,7 +205,7 @@ void ast_sip_location_retrieve_contact_and_aor_from_list(const char *aor_list, s
*aor = NULL;
*contact = NULL;
- while ((aor_name = strsep(&rest, ","))) {
+ while ((aor_name = ast_strip(strsep(&rest, ",")))) {
*aor = ast_sip_location_retrieve_aor(aor_name);
if (!(*aor)) {
@@ -377,12 +377,16 @@ static int permanent_uri_handler(const struct aco_option *opt, struct ast_variab
}
contacts = ast_strdupa(var->value);
- while ((contact_uri = strsep(&contacts, ","))) {
+ while ((contact_uri = ast_strip(strsep(&contacts, ",")))) {
struct ast_sip_contact *contact;
struct ast_sip_contact_status *status;
char hash[33];
char contact_id[strlen(aor_id) + sizeof(hash) + 2];
+ if (ast_strlen_zero(contact_uri)) {
+ continue;
+ }
+
if (!aor->permanent_contacts) {
aor->permanent_contacts = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK,
AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, permanent_uri_sort_fn, NULL);
@@ -442,7 +446,7 @@ int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg)
}
copy = ast_strdupa(aors);
- while ((name = strsep(&copy, ","))) {
+ while ((name = ast_strip(strsep(&copy, ",")))) {
RAII_VAR(struct ast_sip_aor *, aor,
ast_sip_location_retrieve_aor(name), ao2_cleanup);
@@ -454,7 +458,6 @@ int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg)
return -1;
}
}
- ast_free(copy);
return 0;
}
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 2a81cfded..371e4318b 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -410,7 +410,7 @@ int ast_sip_auth_vector_init(struct ast_sip_auth_vector *auths, const char *valu
return -1;
}
- while ((val = strsep(&auth_names, ","))) {
+ while ((val = ast_strip(strsep(&auth_names, ",")))) {
if (ast_strlen_zero(val)) {
continue;
}
@@ -477,7 +477,11 @@ static int ident_handler(const struct aco_option *opt, struct ast_variable *var,
char *idents = ast_strdupa(var->value);
char *val;
- while ((val = strsep(&idents, ","))) {
+ while ((val = ast_strip(strsep(&idents, ",")))) {
+ if (ast_strlen_zero(val)) {
+ continue;
+ }
+
if (!strcasecmp(val, "username")) {
endpoint->ident_method |= AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME;
} else {
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 73f12a00c..aed962030 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -270,7 +270,7 @@ static int on_endpoint(void *obj, void *arg, int flags)
}
aors = ast_strdupa(endpoint->aors);
- while ((aor_name = strsep(&aors, ","))) {
+ while ((aor_name = ast_strip(strsep(&aors, ",")))) {
struct ast_sip_aor *aor;
struct ao2_container *contacts;
@@ -795,7 +795,7 @@ static int cli_qualify_contacts(void *data)
}
aors = ast_strdupa(endpoint->aors);
- while ((aor_name = strsep(&aors, ","))) {
+ while ((aor_name = ast_strip(strsep(&aors, ",")))) {
struct ast_sip_aor *aor;
struct ao2_container *contacts;
@@ -899,7 +899,7 @@ static int ami_sip_qualify(struct mansession *s, const struct message *m)
}
aors = ast_strdupa(endpoint->aors);
- while ((aor_name = strsep(&aors, ","))) {
+ while ((aor_name = ast_strip(strsep(&aors, ",")))) {
struct ast_sip_aor *aor;
struct ao2_container *contacts;
@@ -1087,7 +1087,7 @@ static int qualify_and_schedule_all_cb(void *obj, void *arg, int flags)
}
aors = ast_strdupa(endpoint->aors);
- while ((aor_name = strsep(&aors, ","))) {
+ while ((aor_name = ast_strip(strsep(&aors, ",")))) {
struct ast_sip_aor *aor;
struct ao2_container *contacts;