<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19958">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_agi: RECORD FILE plays 2 beeps.<br><br>Sending the "RECORD FILE" command without the optional<br>`offset_samples` argument can result in two beeps playing on the<br>channel.<br><br>This bug has been present since Asterisk 0.3.0 (2003-02-06).<br><br>ASTERISK-30457 #close<br><br>Change-Id: I95e88aa59378784d7f0eb648843f090e6723b787<br>---<br>M res/res_agi.c<br>1 file changed, 28 insertions(+), 5 deletions(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_agi.c b/res/res_agi.c</span><br><span>index cafe13b..6debae1 100644</span><br><span>--- a/res/res_agi.c</span><br><span>+++ b/res/res_agi.c</span><br><span>@@ -2955,12 +2955,18 @@</span><br><span> </span><br><span>       /* backward compatibility, if no offset given, arg[6] would have been</span><br><span>         * caught below and taken to be a beep, else if it is a digit then it is a</span><br><span style="color: hsl(0, 100%, 40%);">-       * offset */</span><br><span style="color: hsl(0, 100%, 40%);">-    if ((argc >6) && (sscanf(argv[6], "%30ld", &sample_offset) != 1) && (!strchr(argv[6], '=')))</span><br><span style="color: hsl(120, 100%, 40%);">+  * offset.</span><br><span style="color: hsl(120, 100%, 40%);">+     *</span><br><span style="color: hsl(120, 100%, 40%);">+     * In other words, if the argument does not look like the offset_samples</span><br><span style="color: hsl(120, 100%, 40%);">+       * argument (a number) and it doesn't look like the silence argument (starts</span><br><span style="color: hsl(120, 100%, 40%);">+       * with "s=") then it must be the beep argument. The beep argument has no</span><br><span style="color: hsl(120, 100%, 40%);">+    * required value, the presence of anything in the argument slot we are</span><br><span style="color: hsl(120, 100%, 40%);">+        * inspecting is an indication that the user wants a beep played.</span><br><span style="color: hsl(120, 100%, 40%);">+      */</span><br><span style="color: hsl(120, 100%, 40%);">+   if ((argc > 6 && sscanf(argv[6], "%30ld", &sample_offset) != 1 && !ast_begins_with(argv[6], "s="))</span><br><span style="color: hsl(120, 100%, 40%);">+    || (argc > 7 && !ast_begins_with(argv[7], "s="))) {</span><br><span>          res = ast_streamfile(chan, "beep", ast_channel_language(chan));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       if ((argc > 7) && (!strchr(argv[7], '=')))</span><br><span style="color: hsl(0, 100%, 40%);">-           res = ast_streamfile(chan, "beep", ast_channel_language(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span> </span><br><span>        if (!res)</span><br><span>            res = ast_waitstream(chan, argv[4]);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19958">change 19958</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/+/19958"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 20 </div>
<div style="display:none"> Gerrit-Change-Id: I95e88aa59378784d7f0eb648843f090e6723b787 </div>
<div style="display:none"> Gerrit-Change-Number: 19958 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.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: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>