[Asterisk-cvs] asterisk/apps app_senddtmf.c,1.1,1.2

jeremy at lists.digium.com jeremy at lists.digium.com
Tue Mar 23 22:51:44 CST 2004


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv14432/apps

Modified Files:
	app_senddtmf.c 
Log Message:
check input for errors. Bug #435


Index: app_senddtmf.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_senddtmf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- app_senddtmf.c	14 Oct 2002 05:30:28 -0000	1.1
+++ app_senddtmf.c	24 Mar 2004 03:48:18 -0000	1.2
@@ -30,8 +30,9 @@
 static char *synopsis = "Sends arbitrary DTMF digits";
 
 static char *descrip = 
-"  SendDTMF(digits): Sends DTMF digits on a channel.  Returns 0 on success"
-"or -1 on a hangup.\n";
+"  SendDTMF(digits): Sends DTMF digits on a channel. \n"
+"  Accepted digits: 0-9, *#abcd\n"
+" Returns 0 on success or -1 on a hangup.\n";
 
 STANDARD_LOCAL_USER;
 
@@ -45,7 +46,7 @@
 	struct ast_frame f;
 	int x;
 	if (!digits || !strlen(digits)) {
-		ast_log(LOG_WARNING, "SendDTMF requires an argument (digits)\n");
+		ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#abcd)\n");
 		return -1;
 	}
 	LOCAL_USER_ADD(u);
@@ -55,12 +56,17 @@
 		f.subclass = digits[x];
 		f.src = "app_senddtmf";
 		res = ast_write(chan, &f);
-		if (res)
+		 if (strchr("0123456789*#abcd",digits[x])==NULL) {
+                       ast_log(LOG_WARNING, "Illegal DTMF character in string. (0-9*#abcd allowed)\n");
+               } else {
+                  res = ast_write(chan, &f);
+		  if (res)
 			break;
-		/* Wait 250ms */
-		res = ast_safe_sleep(chan, 250);
-		if (res)
+		  /* Wait 250ms */
+		  res = ast_safe_sleep(chan, 250);
+		  if (res)
 			break;
+	       }
 	}
 	if (!res)
 		if (option_verbose > 2)




More information about the svn-commits mailing list