[Asterisk-cvs] asterisk pbx.c,1.105,1.106

markster at lists.digium.com markster at lists.digium.com
Fri Mar 19 01:41:14 CST 2004


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

Modified Files:
	pbx.c 
Log Message:
Fix LEN segfault (bug #1228)


Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- pbx.c	6 Mar 2004 20:15:08 -0000	1.105
+++ pbx.c	19 Mar 2004 06:36:25 -0000	1.106
@@ -751,7 +751,20 @@
 		headp=&c->varshead;
     *ret=NULL;
         /* Now we have the variable name on cp3 */
-	if ((first=strchr(var,':'))) {
+	if (!strncasecmp(var,"LEN(",4)) {
+		int len=strlen(var);
+		int len_len=4;
+		if (strrchr(var,')')) {
+			char cp3[80];
+			strncpy(cp3, var, sizeof(cp3) - 1);
+			cp3[len-len_len-1]='\0';
+			sprintf(workspace,"%d",strlen(cp3));
+			*ret = workspace;
+		} else {
+			/* length is zero */
+			*ret = "0";
+		}
+	} else if ((first=strchr(var,':'))) {
 		strncpy(tmpvar, var, sizeof(tmpvar) - 1);
 		first = strchr(tmpvar, ':');
 		if (!first)
@@ -928,17 +941,6 @@
 					*ret = workspace;
 				}
 			}
-		}
-		if (!(*ret) && !strncasecmp(var,"LEN(",4)) {
-			int len=strlen(var);
-			int len_len=4;
-			if (len > (len_len+1) && !strncasecmp(var,"LEN(",len_len) && strchr(var+len_len+2,')')) {
-				char cp3[80];
-				strncpy(cp3, var, sizeof(cp3) - 1);
-				cp3[len-len_len-1]='\0';
-				sprintf(workspace,"%d",strlen(cp3));
-				*ret = workspace;
-			} else ast_log(LOG_NOTICE, "Wrong use of LEN(VARIABLE)\n");
 		}
 	}
 }




More information about the svn-commits mailing list