From ed6c43287496665ff6cd42c53f8064f44e6d016f Mon Sep 17 00:00:00 2001 From: Pedro Kiefer Date: Thu, 29 Nov 2012 17:17:11 +0000 Subject: [PATCH] Fix chan_sip websocket payload handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Websocket by default doesn't return an ast_str for the payload received. When converting it to an ast_str on chan_sip the last character was being omitted, because ast_str functions expects that the given length includes the trailing 0x00. payload_len only has the actual string length without counting the trailing zero. For most cases this passed unnoticed as most of SIP messages ends with \r\n. (closes issue ASTERISK-20745) Reported by: IƱaki Baz Castillo Review: https://reviewboard.asterisk.org/r/2219/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@376822 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index a9d9c86c00..ee16ddbecb 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2593,7 +2593,7 @@ static void sip_websocket_callback(struct ast_websocket *session, struct ast_var if (opcode == AST_WEBSOCKET_OPCODE_TEXT || opcode == AST_WEBSOCKET_OPCODE_BINARY) { struct sip_request req = { 0, }; - if (!(req.data = ast_str_create(payload_len))) { + if (!(req.data = ast_str_create(payload_len + 1))) { goto end; }