[Asterisk-code-review] res_http_websocket: Add trailing zero for text strings (asterisk[master])

Nickolay V. Shmyrev asteriskteam at digium.com
Thu Jul 2 17:25:58 CDT 2020


Nickolay V. Shmyrev has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14626 )


Change subject: res_http_websocket: Add trailing zero for text strings
......................................................................

res_http_websocket: Add trailing zero for text strings

Per RFC example https://tools.ietf.org/html/rfc6455#section-5.7 text
message payload does not include trailing zero. Add trailing zero after
payload we received before we return string.

ASTERISK-28975 #close

Change-Id: Ib4a75cffeb1eb8cf01136ef30306bd623e531a2a
---
M res/res_http_websocket.c
1 file changed, 3 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/26/14626/1

diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 5d14ac6..1a2a850 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -1471,7 +1471,9 @@
 		return -1;
 	}
 
-	ast_copy_string(*buf, payload, payload_len + 1);
+	memcpy(*buf, payload, payload_len);
+	(*buf)[payload_len] = 0;
+
 	return payload_len + 1;
 }
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14626
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib4a75cffeb1eb8cf01136ef30306bd623e531a2a
Gerrit-Change-Number: 14626
Gerrit-PatchSet: 1
Gerrit-Owner: Nickolay V. Shmyrev <nshmyrev at alphacephei.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200702/a41b18d8/attachment.html>


More information about the asterisk-code-review mailing list