[Asterisk-code-review] res pjsip rfc3326: doesn't account for more than one 'Reason... (asterisk[13])
Ross Beer
asteriskteam at digium.com
Wed Mar 14 11:18:44 CDT 2018
Ross Beer has uploaded this change for review. ( https://gerrit.asterisk.org/8522
Change subject: res_pjsip_rfc3326: doesn't account for more than one 'Reason' header
......................................................................
res_pjsip_rfc3326: doesn't account for more than one 'Reason' header
ASTERISK-27741
Change-Id: I0aa59a54735c6d20b95c54db1bd095dbf93e7adf
---
M res/res_pjsip_rfc3326.c
1 file changed, 27 insertions(+), 20 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/22/8522/1
diff --git a/res/res_pjsip_rfc3326.c b/res/res_pjsip_rfc3326.c
index f467e22..fcc83ed 100644
--- a/res/res_pjsip_rfc3326.c
+++ b/res/res_pjsip_rfc3326.c
@@ -36,32 +36,39 @@
static void rfc3326_use_reason_header(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
- const pj_str_t str_reason = { "Reason", 6 };
- pjsip_generic_string_hdr *header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL);
- char buf[20], *cause, *text;
- int code;
+ const pj_str_t str_reason = { "Reason", 6 };
+ int header_pos = 0;
+ pjsip_generic_string_hdr *header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, &header_pos);
+ char buf[20], *cause, *text;
+ int code;
- if (!header) {
- return;
- }
+ if (!header) {
+ return;
+ }
- ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));
- cause = ast_skip_blanks(buf);
+ while(header)
+ {
+ ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));
+ cause = ast_skip_blanks(buf);
- if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) {
- return;
- }
+ if (strncasecmp(cause, "Q.850", 5) && (cause = strstr(cause, "cause="))) {
- /* If text is present get rid of it */
- if ((text = strstr(cause, ";"))) {
- *text = '\0';
- }
+ /* If text is present get rid of it */
+ if ((text = strstr(cause, ";"))) {
+ *text = '\0';
+ }
- if (sscanf(cause, "cause=%30d", &code) != 1) {
- return;
- }
+ if (sscanf(cause, "cause=%30d", &code) != 1) {
+ break;
+ }
- ast_channel_hangupcause_set(session->channel, code & 0x7f);
+ ast_channel_hangupcause_set(session->channel, code & 0x7f);
+ break;
+ }
+
+ header_pos++;
+ header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, &header_pos);
+ }
}
static int rfc3326_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
--
To view, visit https://gerrit.asterisk.org/8522
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0aa59a54735c6d20b95c54db1bd095dbf93e7adf
Gerrit-Change-Number: 8522
Gerrit-PatchSet: 1
Gerrit-Owner: Ross Beer <ross.beer at voicehost.co.uk>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180314/0973bdad/attachment-0001.html>
More information about the asterisk-code-review
mailing list