[Asterisk-code-review] res_pjsip: Check return from pjsip_parse_uri calls (...asterisk[certified/13.21])

George Joseph asteriskteam at digium.com
Thu May 2 13:37:43 CDT 2019


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/11336


Change subject: res_pjsip:  Check return from pjsip_parse_uri calls
......................................................................

res_pjsip:  Check return from pjsip_parse_uri calls

Updated ast_sip_create_rdata_with_contact and registrar_find_contact
to check the return from pjsip_parse_uri before attempting to
use the uri returned.

ASTERISK-28402
Reported-by: Ross Beer

Change-Id: I9810b3b163c45ed5a56ec743586e5ce107f13ba7
---
M res/res_pjsip.c
M res/res_pjsip_registrar.c
2 files changed, 15 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/36/11336/1

diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index b063d3d..4c3343d 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3394,6 +3394,10 @@
 		if (contact_hdr) {
 			contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (char *)contact,
 				strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
+			if (!contact_hdr->uri) {
+				ast_log(LOG_WARNING, "Unable to parse contact URI from '%s'.\n", contact);
+				return -1;
+			}
 		}
 	}
 
diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c
index bf51733..c72ac19 100644
--- a/res/res_pjsip_registrar.c
+++ b/res/res_pjsip_registrar.c
@@ -122,7 +122,17 @@
 {
 	struct ast_sip_contact *contact = obj;
 	const struct registrar_contact_details *details = arg;
-	pjsip_uri *contact_uri = pjsip_parse_uri(details->pool, (char*)contact->uri, strlen(contact->uri), 0);
+	pjsip_uri *contact_uri;
+
+	if (ast_tvzero(contact->expiration_time)) {
+		return 0;
+	}
+
+	contact_uri = pjsip_parse_uri(details->pool, (char*)contact->uri, strlen(contact->uri), 0);
+	if (!contact_uri) {
+		ast_log(LOG_WARNING, "Unable to parse contact URI from '%s'.\n", contact->uri);
+		return 0;
+	}
 
 	return (pjsip_uri_cmp(PJSIP_URI_IN_CONTACT_HDR, details->uri, contact_uri) == PJ_SUCCESS) ? CMP_MATCH : 0;
 }

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11336
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: certified/13.21
Gerrit-Change-Id: I9810b3b163c45ed5a56ec743586e5ce107f13ba7
Gerrit-Change-Number: 11336
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190502/28539e61/attachment-0001.html>


More information about the asterisk-code-review mailing list