[Asterisk-code-review] res_agi: RECORD FILE plays 2 beeps.	(asterisk[20])
    Joshua Colp 
    asteriskteam at digium.com
       
    Thu Mar 16 10:43:21 CDT 2023
    
    
  
Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19958 )
Change subject: res_agi: RECORD FILE plays 2 beeps.
......................................................................
res_agi: RECORD FILE plays 2 beeps.
Sending the "RECORD FILE" command without the optional
`offset_samples` argument can result in two beeps playing on the
channel.
This bug has been present since Asterisk 0.3.0 (2003-02-06).
ASTERISK-30457 #close
Change-Id: I95e88aa59378784d7f0eb648843f090e6723b787
---
M res/res_agi.c
1 file changed, 28 insertions(+), 5 deletions(-)
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
diff --git a/res/res_agi.c b/res/res_agi.c
index cafe13b..6debae1 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -2955,12 +2955,18 @@
 
 	/* backward compatibility, if no offset given, arg[6] would have been
 	 * caught below and taken to be a beep, else if it is a digit then it is a
-	 * offset */
-	if ((argc >6) && (sscanf(argv[6], "%30ld", &sample_offset) != 1) && (!strchr(argv[6], '=')))
+	 * offset.
+	 *
+	 * In other words, if the argument does not look like the offset_samples
+	 * argument (a number) and it doesn't look like the silence argument (starts
+	 * with "s=") then it must be the beep argument. The beep argument has no
+	 * required value, the presence of anything in the argument slot we are
+	 * inspecting is an indication that the user wants a beep played.
+	 */
+	if ((argc > 6 && sscanf(argv[6], "%30ld", &sample_offset) != 1 && !ast_begins_with(argv[6], "s="))
+	   || (argc > 7 && !ast_begins_with(argv[7], "s="))) {
 		res = ast_streamfile(chan, "beep", ast_channel_language(chan));
-
-	if ((argc > 7) && (!strchr(argv[7], '=')))
-		res = ast_streamfile(chan, "beep", ast_channel_language(chan));
+	}
 
 	if (!res)
 		res = ast_waitstream(chan, argv[4]);
-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19958
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 20
Gerrit-Change-Id: I95e88aa59378784d7f0eb648843f090e6723b787
Gerrit-Change-Number: 19958
Gerrit-PatchSet: 2
Gerrit-Owner: Sean Bright <sean at seanbright.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230316/105819b1/attachment.html>
    
    
More information about the asterisk-code-review
mailing list