<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10916">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_http_websocket: ensure control frames do not interfere with data<br><br>Control frames (PING / PONG / CLOSE) can be received in the middle of a<br>fragmented message. In order to ensure they do not interfere with the<br>reassembly buffer, we exit early and do not return the payload to the<br>caller.<br><br>ASTERISK-28257 #close<br><br>Change-Id: Ia5367144fe08ac6141bba3309517a48ec7f013bc<br>---<br>M res/res_http_websocket.c<br>1 file changed, 11 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c</span><br><span>index a44f601..e79066b 100644</span><br><span>--- a/res/res_http_websocket.c</span><br><span>+++ b/res/res_http_websocket.c</span><br><span>@@ -632,9 +632,17 @@</span><br><span>              }</span><br><span> </span><br><span>                /* Per the RFC for PING we need to send back an opcode with the application data as received */</span><br><span style="color: hsl(0, 100%, 40%);">-         if ((*opcode == AST_WEBSOCKET_OPCODE_PING) && (ast_websocket_write(session, AST_WEBSOCKET_OPCODE_PONG, *payload, *payload_len))) {</span><br><span style="color: hsl(120, 100%, 40%);">+            if (*opcode == AST_WEBSOCKET_OPCODE_PING) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   if (ast_websocket_write(session, AST_WEBSOCKET_OPCODE_PONG, *payload, *payload_len)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                ast_websocket_close(session, 1009);</span><br><span style="color: hsl(120, 100%, 40%);">+                   }</span><br><span>                    *payload_len = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-                       ast_websocket_close(session, 1009);</span><br><span style="color: hsl(120, 100%, 40%);">+                   return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           /* Stop PONG processing here */</span><br><span style="color: hsl(120, 100%, 40%);">+               if (*opcode == AST_WEBSOCKET_OPCODE_PONG) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   *payload_len = 0;</span><br><span>                    return 0;</span><br><span>            }</span><br><span> </span><br><span>@@ -648,6 +656,7 @@</span><br><span>                  return 0;</span><br><span>            }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+         /* Below this point we are handling TEXT, BINARY or CONTINUATION opcodes */</span><br><span>          if (*payload_len) {</span><br><span>                  if (!(new_payload = ast_realloc(session->payload, (session->payload_len + *payload_len)))) {</span><br><span>                           ast_log(LOG_WARNING, "Failed allocation: %p, %zu, %"PRIu64"\n",</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10916">change 10916</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10916"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ia5367144fe08ac6141bba3309517a48ec7f013bc </div>
<div style="display:none"> Gerrit-Change-Number: 10916 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Jeremy LainĂ© <jeremy.laine@m4x.org> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>