[asterisk-commits] trunk r34463 - /trunk/channels/chan_local.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jun 16 05:55:18 MST 2006


Author: bweschke
Date: Fri Jun 16 07:55:18 2006
New Revision: 34463

URL: http://svn.digium.com/view/asterisk?rev=34463&view=rev
Log:
 Quit early and print a LOG_WARNING if we are trying to check devicestate on a Local channel that's been improperly defined.


Modified:
    trunk/channels/chan_local.c

Modified: trunk/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_local.c?rev=34463&r1=34462&r2=34463&view=diff
==============================================================================
--- trunk/channels/chan_local.c (original)
+++ trunk/channels/chan_local.c Fri Jun 16 07:55:18 2006
@@ -126,16 +126,23 @@
 	int res;
 		
 	exten = ast_strdupa(data);
-	if ((context  = strchr(exten, '@'))) {
-		*context = '\0';
-		context = context + 1;
-	}
+	context = strchr(exten, '@');
+
+	if (!context) {
+		ast_log(LOG_WARNING, "Someone used Local/%s somewhere without a @context. This is bad.\n", exten);
+		return AST_DEVICE_INVALID;	
+	}
+
+	*context = '\0';
+	context = context + 1;
+
 	if (option_debug > 2)
 		ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
 	res = ast_exists_extension(NULL, context, exten, 1, NULL);
-	if (!res)
+	if (!res) {
+		
 		return AST_DEVICE_INVALID;
-	else
+	} else
 		return AST_DEVICE_UNKNOWN;
 }
 



More information about the asterisk-commits mailing list