]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Avoid crash when contact uri is empty string
authorAaron An <anjb@ti-net.com.cn>
Mon, 6 Nov 2017 04:06:15 +0000 (12:06 +0800)
committerJoshua Colp <jcolp@digium.com>
Tue, 7 Nov 2017 15:33:06 +0000 (10:33 -0500)
Asterisk will crash if contact uri is invalid, so contact_apply_handler
should check if the uri is NULL or empty.

ASTERISK-27393 #close
Reported-by: Aaron An
Tested-by: AaronAn
Change-Id: Ia0309bdc6b697c73c9c736e1caec910b77ca69f5

res/res_pjsip/location.c

index 66fc85c9527b487005a1641975298eb4d85266ab..8ba409e2e08d27316b07435caf56e716270f3679 100644 (file)
@@ -1226,6 +1226,11 @@ static int contact_apply_handler(const struct ast_sorcery *sorcery, void *object
        struct ast_sip_contact_status *status;
        struct ast_sip_contact *contact = object;
 
+       if (ast_strlen_zero(contact->uri)) {
+               ast_log(LOG_ERROR, "A URI on dynamic contact '%s' is empty\n",
+                       ast_sorcery_object_get_id(contact));
+               return -1;
+       }
        status = ast_res_pjsip_find_or_create_contact_status(contact);
        ao2_cleanup(status);