]> git.ipfire.org Git - thirdparty/asterisk.git/commit
chan_websocket: Fix buffer overrun when processing TEXT websocket frames.
authorGeorge Joseph <gjoseph@sangoma.com>
Tue, 19 Aug 2025 15:46:39 +0000 (09:46 -0600)
committerGeorge Joseph <gjoseph@sangoma.com>
Wed, 17 Sep 2025 19:36:51 +0000 (13:36 -0600)
commit76a68acc6e8f159653a688d4d4658d9c6fc0183b
treead9802ac3ce169eee6bb1ae46e64800f216c7111
parent3e9c15754c3ac581c59db3e948938d468fde99f5
chan_websocket: Fix buffer overrun when processing TEXT websocket frames.

ast_websocket_read() receives data into a fixed 64K buffer then continually
reallocates a final buffer that, after all continuation frames have been
received, is the exact length of the data received and returns that to the
caller.  process_text_message() in chan_websocket was attempting to set a
NULL terminator on the received payload assuming the payload buffer it
received was the large 64K buffer.  The assumption was incorrect so when it
tried to set a NULL terminator on the payload, it could, depending on the
state of the heap at the time, cause heap corruption.

process_text_message() now allocates its own payload_len + 1 sized buffer,
copies the payload received from ast_websocket_read() into it then NULL
terminates it prevent the possibility of the overrun and corruption.

Resolves: #1384
(cherry picked from commit 72d1b469fd589c914ee68fe04f6e8f04af80ca59)
channels/chan_websocket.c