[asterisk-commits] file: branch file/bridging r111853 - /team/file/bridging/main/bridging.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 28 15:57:43 CDT 2008


Author: file
Date: Fri Mar 28 15:57:43 2008
New Revision: 111853

URL: http://svn.digium.com/view/asterisk?view=rev&rev=111853
Log:
Define the maximum length of a DTMF feature string and use it around the code. As well keep track of the current length of DTMF string when trying to match it against a feature and make sure it does not exceed the maximum DTMF feature string length.

Modified:
    team/file/bridging/main/bridging.c

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=111853&r1=111852&r2=111853
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Fri Mar 28 15:57:43 2008
@@ -42,8 +42,11 @@
 
 static AST_RWLIST_HEAD_STATIC(bridge_technologies, ast_bridge_technology);
 
+/* Maximum length of a DTMF feature string */
+#define MAXIMUM_DTMF_FEATURE_STRING 8
+
 /*! Default DTMF keys for built in features */
-static char builtin_features_dtmf[AST_BRIDGE_BUILTIN_END][8];
+static char builtin_features_dtmf[AST_BRIDGE_BUILTIN_END][MAXIMUM_DTMF_FEATURE_STRING];
 
 int __ast_bridge_technology_register(struct ast_bridge_technology *technology, struct ast_module *module)
 {
@@ -674,8 +677,8 @@
 {
 	struct ast_bridge_features *features = (bridge_channel->features ? bridge_channel->features : &bridge->features);
 	struct ast_bridge_features_hook *hook = NULL;
-	char dtmf[8] = "";
-	int look_for_dtmf = 1;
+	char dtmf[MAXIMUM_DTMF_FEATURE_STRING] = "";
+	int look_for_dtmf = 1, dtmf_len = 0;
 
 	/* Don't bother with the bridge anymore, it's not going to go away */
 	ast_mutex_unlock(&bridge->lock);
@@ -694,7 +697,7 @@
 		}
 
 		/* Add the above DTMF into the DTMF string so we can do our matching */
-		dtmf[strlen(dtmf)] = res;
+		dtmf[dtmf_len++] = res;
 
 		ast_debug(1, "DTMF feature string on bridge channel %p is now '%s'\n", bridge_channel, dtmf);
 
@@ -707,12 +710,17 @@
 			if (!strcmp(hook->dtmf, dtmf)) {
 				ast_debug(1, "DTMF feature hook %p matched DTMF string '%s' on bridge channel %p\n", hook, dtmf, bridge_channel);
 				break;
-			} else if (!strncmp(hook->dtmf, dtmf, strlen(dtmf))) {
+			} else if (!strncmp(hook->dtmf, dtmf, dtmf_len)) {
 				ast_debug(1, "DTMF feature hook %p can match DTMF string '%s', it wants '%s', on bridge channel %p\n", hook, dtmf, hook->dtmf, bridge_channel);
 				look_for_dtmf = 1;
 			} else {
 				ast_debug(1, "DTMF feature hook %p does not match DTMF string '%s', it wants '%s', on bridge channel %p\n", hook, dtmf, hook->dtmf, bridge_channel);
 			}
+		}
+
+		/* If we have reached the maximum length of a DTMF feature string bail out */
+		if (dtmf_len == MAXIMUM_DTMF_FEATURE_STRING) {
+			break;
 		}
 	}
 




More information about the asterisk-commits mailing list