[Asterisk-cvs] asterisk pbx.c,1.96.2.8,1.96.2.9

markster at lists.digium.com markster at lists.digium.com
Fri Mar 19 01:40:39 CST 2004


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

Modified Files:
      Tag: v1-0_stable
	pbx.c 
Log Message:
Fix LEN segfault (bug #1228)


Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.96.2.8
retrieving revision 1.96.2.9
diff -u -d -r1.96.2.8 -r1.96.2.9
--- pbx.c	6 Mar 2004 20:16:34 -0000	1.96.2.8
+++ pbx.c	19 Mar 2004 06:35:51 -0000	1.96.2.9
@@ -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)
@@ -925,17 +938,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