<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8253">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
Corey Farrell: Looks good to me, but someone else must approve
Matthew Fredrickson: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_http_websocket: Don't leak memory on read failure<br><br>Change-Id: Ic449ea832bc81a1671c0e910c5fbe8c683e3da89<br>---<br>M res/res_http_websocket.c<br>1 file changed, 18 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c<br>index 956c52c..440bf41 100644<br>--- a/res/res_http_websocket.c<br>+++ b/res/res_http_websocket.c<br>@@ -661,18 +661,27 @@<br> session->payload_len = 0;<br> }<br> } else if (*opcode == AST_WEBSOCKET_OPCODE_CLOSE) {<br>+ session->closing = 1;<br>+<br> /* Make the payload available so the user can look at the reason code if they so desire */<br>- if ((*payload_len) && (new_payload = ast_realloc(session->payload, *payload_len))) {<br>- if (ws_safe_read(session, &buf[frame_size], (*payload_len), opcode)) {<br>- return -1;<br>- }<br>- session->payload = new_payload;<br>- memcpy(session->payload, &buf[frame_size], *payload_len);<br>- *payload = session->payload;<br>- frame_size += (*payload_len);<br>+ if (!*payload_len) {<br>+ return 0;<br> }<br> <br>- session->closing = 1;<br>+ if (!(new_payload = ast_realloc(session->payload, *payload_len))) {<br>+ ast_log(LOG_WARNING, "Failed allocation: %p, %"PRIu64"\n",<br>+ session->payload, *payload_len);<br>+ *payload_len = 0;<br>+ return -1;<br>+ }<br>+<br>+ session->payload = new_payload;<br>+ if (ws_safe_read(session, &buf[frame_size], *payload_len, opcode)) {<br>+ return -1;<br>+ }<br>+ memcpy(session->payload, &buf[frame_size], *payload_len);<br>+ *payload = session->payload;<br>+ frame_size += *payload_len;<br> } else {<br> ast_log(LOG_WARNING, "WebSocket unknown opcode %u\n", *opcode);<br> /* We received an opcode that we don't understand, the RFC states that 1003 is for a type of data that can't be accepted... opcodes<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8253">change 8253</a>. To unsubscribe, 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/8253"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ic449ea832bc81a1671c0e910c5fbe8c683e3da89 </div>
<div style="display:none"> Gerrit-Change-Number: 8253 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matthew Fredrickson <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>