asterisk-13.x: fix AST-2019-002 & AST-2019-003
[feed/telephony.git] / net / asterisk-13.x / patches / 110-AST-2019-002-13.diff
1 From a9d8b56831146166abc7fb8abe8ae8aaff295358 Mon Sep 17 00:00:00 2001
2 From: George Joseph <gjoseph@digium.com>
3 Date: Wed, 12 Jun 2019 12:03:04 -0600
4 Subject: [PATCH] res_pjsip_messaging: Check for body in in-dialog message
5
6 We now check that a body exists and it has a length > 0 before
7 attempting to process it.
8
9 ASTERISK-28447
10 Reported-by: Gil Richard
11
12 Change-Id: Ic469544b22ab848734636588d4c93426cc6f4b1f
13 ---
14
15 diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
16 index 10c5f29..76d37f2 100644
17 --- a/res/res_pjsip_messaging.c
18 +++ b/res/res_pjsip_messaging.c
19 @@ -91,10 +91,13 @@
20 static const pj_str_t text = { "text", 4};
21 static const pj_str_t application = { "application", 11};
22
23 + if (!(rdata->msg_info.msg->body && rdata->msg_info.msg->body->len > 0)) {
24 + return res;
25 + }
26 +
27 /* We'll accept any text/ or application/ content type */
28 - if (rdata->msg_info.msg->body && rdata->msg_info.msg->body->len
29 - && (pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0
30 - || pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &application) == 0)) {
31 + if (pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0
32 + || pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &application) == 0) {
33 res = PJSIP_SC_OK;
34 } else if (rdata->msg_info.ctype
35 && (pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0