<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18122">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">file.c: Prevent formats from seeking negative offsets.<br><br>Currently, if a user uses an application like ControlPlayback<br>to try to rewind a file past the beginning, this can throw<br>warnings when the file format (e.g. PCM) tries to seek to<br>a negative offset.<br><br>Instead of letting file formats try (and fail) to seek a<br>negative offset, we instead now catch this in the rewind<br>function to ensure that we never seek an offset less than 0.<br>This prevents legitimate user actions from triggering warnings<br>from any particular file formats.<br><br>ASTERISK-29943 #close<br><br>Change-Id: Ia53f2623f57898f4b8e5c894b968b01e95426967<br>---<br>M main/file.c<br>1 file changed, 6 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/file.c b/main/file.c</span><br><span>index a6cd300..8bb40da 100644</span><br><span>--- a/main/file.c</span><br><span>+++ b/main/file.c</span><br><span>@@ -1097,6 +1097,12 @@</span><br><span> </span><br><span> int ast_stream_rewind(struct ast_filestream *fs, off_t ms)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+     off_t offset = ast_tellstream(fs);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (ms * DEFAULT_SAMPLES_PER_MS > offset) {</span><br><span style="color: hsl(120, 100%, 40%);">+                /* Don't even bother asking the file format to seek to a negative offset... */</span><br><span style="color: hsl(120, 100%, 40%);">+            ast_debug(1, "Restarting, rather than seeking to negative offset %ld\n", (long) (offset - (ms * DEFAULT_SAMPLES_PER_MS)));</span><br><span style="color: hsl(120, 100%, 40%);">+          return ast_seekstream(fs, 0, SEEK_SET);</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span>    return ast_seekstream(fs, -ms * DEFAULT_SAMPLES_PER_MS, SEEK_CUR);</span><br><span> }</span><br><span> </span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18122">change 18122</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/+/18122"/><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-Change-Id: Ia53f2623f57898f4b8e5c894b968b01e95426967 </div>
<div style="display:none"> Gerrit-Change-Number: 18122 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>