[Asterisk-code-review] res_pjsip_messaging: Check for body in in-dialog message (...asterisk[certified/13.21])

Benjamin Keith Ford asteriskteam at digium.com
Thu Jul 11 13:24:03 CDT 2019


Hello George Joseph,

I'd like you to do a code review. Please visit

    https://gerrit.asterisk.org/c/asterisk/+/11558

to review the following change.


Change subject: res_pjsip_messaging:  Check for body in in-dialog message
......................................................................

res_pjsip_messaging:  Check for body in in-dialog message

We now check that a body exists and it has a length > 0 before
attempting to process it.

ASTERISK-28447
Reported-by: Gil Richard

Change-Id: Ic469544b22ab848734636588d4c93426cc6f4b1f
---
M res/res_pjsip_messaging.c
1 file changed, 11 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/58/11558/1

diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index cbc6ea5..b9d4a87 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -88,14 +88,20 @@
 static enum pjsip_status_code check_content_type_any_text(const pjsip_rx_data *rdata)
 {
 	int res = PJSIP_SC_UNSUPPORTED_MEDIA_TYPE;
-	pj_str_t text = { "text", 4};
+	static const pj_str_t text = { "text", 4};
+	static const pj_str_t application = {"application", 11};
 
-	/* We'll accept any text/ content type */
-	if (rdata->msg_info.msg->body && rdata->msg_info.msg->body->len
-		&& pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0) {
+	if (!(rdata->msg_info.msg->body && rdata->msg_info.msg->body->len > 0)) {
+		return res;
+	}
+
+	/* We'll accept any text/ or application/ content type */
+	if (pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0
+			|| pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &application) == 0) {
 		res = PJSIP_SC_OK;
 	} else if (rdata->msg_info.ctype
-		&& pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0) {
+		&& (pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0
+		|| pj_stricmp(&rdata->msg_info.ctype->media.type, &application) == 0)) {
 		res = PJSIP_SC_OK;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11558
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: Ic469544b22ab848734636588d4c93426cc6f4b1f
Gerrit-Change-Number: 11558
Gerrit-PatchSet: 1
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: 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/20190711/dcd0835f/attachment.html>


More information about the asterisk-code-review mailing list