From a36d8cc53333ce5b6bbeec6552c2ee902de2aa2d Mon Sep 17 00:00:00 2001 From: Aaron An <anjb@ti-net.com.cn> Date: Mon, 6 Nov 2017 12:06:15 +0800 Subject: [PATCH] res_pjsip: Avoid crash when contact uri is empty string 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c index 9945c7c109..0d7b3da311 100644 --- a/res/res_pjsip/location.c +++ b/res/res_pjsip/location.c @@ -1219,6 +1219,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); -- GitLab