Merge "res_pjsip_t38: Don't crash on authenticated reinvite after originated T.38...
authorMatt Jordan <mjordan@digium.com>
Fri, 24 Apr 2015 14:24:54 +0000 (09:24 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Fri, 24 Apr 2015 14:24:54 +0000 (09:24 -0500)
main/event.c
main/security_events.c
res/res_pjsip.c
res/res_pjsip/location.c
res/res_stasis_playback.c
res/res_stasis_recording.c

index 228807d..3af0314 100644 (file)
@@ -199,7 +199,7 @@ const char *ast_event_get_type_name(const struct ast_event *event)
 
        type = ast_event_get_type(event);
 
-       if (type >= ARRAY_LEN(event_names)) {
+       if ((unsigned int)type >= ARRAY_LEN(event_names)) {
                ast_log(LOG_ERROR, "Invalid event type - '%u'\n", type);
                return "";
        }
index 0da62a2..9db932d 100644 (file)
@@ -428,7 +428,7 @@ static struct ast_manager_event_blob *security_event_to_ami_blob(struct ast_json
        event_type_json = ast_json_object_get(json, "SecurityEvent");
        event_type = ast_json_integer_get(event_type_json);
 
-       ast_assert(event_type >= 0 && event_type < AST_SECURITY_EVENT_NUM_TYPES);
+       ast_assert((unsigned int)event_type < AST_SECURITY_EVENT_NUM_TYPES);
 
        if (!(str = ast_str_create(SECURITY_EVENT_BUF_INIT_LEN))) {
                return NULL;
@@ -886,7 +886,7 @@ const char *ast_security_event_severity_get_name(
 
 static int check_event_type(const enum ast_security_event_type event_type)
 {
-       if (event_type >= AST_SECURITY_EVENT_NUM_TYPES) {
+       if ((unsigned int)event_type >= AST_SECURITY_EVENT_NUM_TYPES) {
                ast_log(LOG_ERROR, "Invalid security event type %u\n", event_type);
                return -1;
        }
@@ -1172,7 +1172,7 @@ return_error:
 
 int ast_security_event_report(const struct ast_security_event_common *sec)
 {
-       if (sec->event_type >= AST_SECURITY_EVENT_NUM_TYPES) {
+       if ((unsigned int)sec->event_type >= AST_SECURITY_EVENT_NUM_TYPES) {
                ast_log(LOG_ERROR, "Invalid security event type\n");
                return -1;
        }
index 2bc5abd..a613bcc 100644 (file)
@@ -2723,7 +2723,8 @@ static int create_out_of_dialog_request(const pjsip_method *method, struct ast_s
        if (sip_dialog_create_from(pool, &from, endpoint ? endpoint->fromuser : NULL,
                                endpoint ? endpoint->fromdomain : NULL, &remote_uri, &selector)) {
                ast_log(LOG_ERROR, "Unable to create From header for %.*s request to endpoint %s\n",
-                               (int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
+                               (int) pj_strlen(&method->name), pj_strbuf(&method->name),
+                               endpoint ? ast_sorcery_object_get_id(endpoint) : "<none>");
                pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
                return -1;
        }
@@ -2731,7 +2732,8 @@ static int create_out_of_dialog_request(const pjsip_method *method, struct ast_s
        if (pjsip_endpt_create_request(ast_sip_get_pjsip_endpoint(), method, &remote_uri,
                        &from, &remote_uri, &from, NULL, -1, NULL, tdata) != PJ_SUCCESS) {
                ast_log(LOG_ERROR, "Unable to create outbound %.*s request to endpoint %s\n",
-                               (int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
+                               (int) pj_strlen(&method->name), pj_strbuf(&method->name),
+                               endpoint ? ast_sorcery_object_get_id(endpoint) : "<none>");
                pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
                return -1;
        }
index 2165041..45370dd 100644 (file)
@@ -290,6 +290,8 @@ static int permanent_contact_validate(void *data)
        pj_pool_t *pool;
        pj_str_t contact_uri;
        static const pj_str_t HCONTACT = { "Contact", 7 };
+       pjsip_contact_hdr *contact_hdr;
+       int rc = 0;
 
        pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "Permanent Contact Validation", 256, 256);
        if (!pool) {
@@ -297,13 +299,14 @@ static int permanent_contact_validate(void *data)
        }
 
        pj_strdup2_with_null(pool, &contact_uri, value);
-       if (!pjsip_parse_hdr(pool, &HCONTACT, contact_uri.ptr, contact_uri.slen, NULL)) {
-               pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
-               return -1;
+       if (!(contact_hdr = pjsip_parse_hdr(pool, &HCONTACT, contact_uri.ptr, contact_uri.slen, NULL))
+               || !(PJSIP_URI_SCHEME_IS_SIP(contact_hdr->uri)
+                       || PJSIP_URI_SCHEME_IS_SIPS(contact_hdr->uri))) {
+               rc = -1;
        }
 
        pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
-       return 0;
+       return rc;
 }
 
 static int permanent_uri_sort_fn(const void *obj_left, const void *obj_right, int flags)
index 2d40ec0..7aac06d 100644 (file)
@@ -629,7 +629,7 @@ enum stasis_playback_oper_results stasis_app_playback_operation(
        playback_opreation_cb cb;
        SCOPED_AO2LOCK(lock, playback);
 
-       ast_assert(playback->state < STASIS_PLAYBACK_STATE_MAX);
+       ast_assert((unsigned int)playback->state < STASIS_PLAYBACK_STATE_MAX);
 
        if (operation >= STASIS_PLAYBACK_MEDIA_OP_MAX) {
                ast_log(LOG_ERROR, "Invalid playback operation %u\n", operation);
index 7af9c10..3a10d41 100644 (file)
@@ -595,13 +595,13 @@ enum stasis_app_recording_oper_results stasis_app_recording_operation(
        recording_operation_cb cb;
        SCOPED_AO2LOCK(lock, recording);
 
-       if (recording->state >= STASIS_APP_RECORDING_STATE_MAX) {
+       if ((unsigned int)recording->state >= STASIS_APP_RECORDING_STATE_MAX) {
                ast_log(LOG_WARNING, "Invalid recording state %u\n",
                        recording->state);
                return -1;
        }
 
-       if (operation >= STASIS_APP_RECORDING_OPER_MAX) {
+       if ((unsigned int)operation >= STASIS_APP_RECORDING_OPER_MAX) {
                ast_log(LOG_WARNING, "Invalid recording operation %u\n",
                        operation);
                return -1;