<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10369">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
George Joseph: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">core/frame: Fix ast_frdup() and ast_frisolate() for empty text frames<br><br>If a channel creates an AST_TEXT_FRAME with datalen == 0, the ast_frdup()<br>and ast_frisolate() functions could create a clone frame with an invalid<br>data.ptr which would cause a crash. The proposed fix is to make sure that<br>for such empty text frames, ast_frdup() and ast_frisolate() return cloned<br>text frames with a valid data.ptr.<br><br>ASTERISK-28076<br>Reported by: Emmanuel BUU<br>Tested by: Emmanuel BUU<br><br>Change-Id: Ib882dd028598f13c4c233edbfdd7e54ad44a68e9<br>---<br>M main/frame.c<br>1 file changed, 3 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/frame.c b/main/frame.c</span><br><span>index 383571f..208c82d 100644</span><br><span>--- a/main/frame.c</span><br><span>+++ b/main/frame.c</span><br><span>@@ -259,7 +259,7 @@</span><br><span> </span><br><span> if (!(fr->mallocd & AST_MALLOCD_DATA)) {</span><br><span> /* The original frame has a non-malloced data buffer. */</span><br><span style="color: hsl(0, 100%, 40%);">- if (!fr->datalen) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!fr->datalen && fr->frametype != AST_FRAME_TEXT) {</span><br><span> /* Actually it's just an int so we can simply copy it. */</span><br><span> out->data.uint32 = fr->data.uint32;</span><br><span> return out;</span><br><span>@@ -356,7 +356,8 @@</span><br><span> */</span><br><span> out->mallocd = AST_MALLOCD_HDR;</span><br><span> out->offset = AST_FRIENDLY_OFFSET;</span><br><span style="color: hsl(0, 100%, 40%);">- if (out->datalen) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Make sure that empty text frames have a valid data.ptr */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (out->datalen || f->frametype == AST_FRAME_TEXT) {</span><br><span> out->data.ptr = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;</span><br><span> memcpy(out->data.ptr, f->data.ptr, out->datalen);</span><br><span> } else {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10369">change 10369</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/10369"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ib882dd028598f13c4c233edbfdd7e54ad44a68e9 </div>
<div style="display:none"> Gerrit-Change-Number: 10369 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Emmanuel BUU <emmanuel.buu@ives.fr> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>