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

Friendly Automation asteriskteam at digium.com
Fri May 3 09:18:51 CDT 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11333 )

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, 8 insertions(+), 0 deletions(-)

Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 7773549..ba029f3 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -3517,6 +3517,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 fa3e1f0..236d846 100644
--- a/res/res_pjsip_registrar.c
+++ b/res/res_pjsip_registrar.c
@@ -129,6 +129,10 @@
 	}
 
 	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/+/11333
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I9810b3b163c45ed5a56ec743586e5ce107f13ba7
Gerrit-Change-Number: 11333
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190503/94d6b7d0/attachment.html>


More information about the asterisk-code-review mailing list