<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13200">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">func_env: Prevent FILE() from reading garbage at end-of-file<br><br>If the last line of a file does not have a terminating EOL sequence, we<br>potentially add garbage to the value returned from the FILE() function.<br><br>There is no overflow potential here as we are reading from a buffer of a<br>known size, we are just reading too much of it.<br><br>ASTERISK-26481 #close<br><br>Change-Id: I50dd4fcf416fb3c83150040a1a79a59d9eb1ae01<br>---<br>M funcs/func_env.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/funcs/func_env.c b/funcs/func_env.c</span><br><span>index 861adeb..e625853 100644</span><br><span>--- a/funcs/func_env.c</span><br><span>+++ b/funcs/func_env.c</span><br><span>@@ -709,12 +709,13 @@</span><br><span>               ast_debug(3, "offset=%" PRId64 ", length=%" PRId64 ", offset_offset=%" PRId64 ", length_offset=%" PRId64 "\n", offset, length, offset_offset, length_offset);</span><br><span>              for (i = offset_offset; i < flength; i += sizeof(fbuf)) {</span><br><span>                         char *pos;</span><br><span style="color: hsl(0, 100%, 40%);">-                      if (fread(fbuf, 1, sizeof(fbuf), ff) < sizeof(fbuf) && !feof(ff)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                        size_t bytes_read;</span><br><span style="color: hsl(120, 100%, 40%);">+                    if ((bytes_read = fread(fbuf, 1, sizeof(fbuf), ff)) < sizeof(fbuf) && !feof(ff)) {</span><br><span>                                ast_log(LOG_ERROR, "Short read?!!\n");</span><br><span>                             fclose(ff);</span><br><span>                          return -1;</span><br><span>                   }</span><br><span style="color: hsl(0, 100%, 40%);">-                       for (pos = fbuf; pos < fbuf + sizeof(fbuf); pos++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                       for (pos = fbuf; pos < fbuf + bytes_read; pos++) {</span><br><span>                                LINE_COUNTER(pos, format, current_length);</span><br><span> </span><br><span>                               if (current_length == length) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13200">change 13200</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/c/asterisk/+/13200"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 17 </div>
<div style="display:none"> Gerrit-Change-Id: I50dd4fcf416fb3c83150040a1a79a59d9eb1ae01 </div>
<div style="display:none"> Gerrit-Change-Number: 13200 </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: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>