File 0340-bnc458541-2479947-valueList.patch of Package sblim-sfcb

--- cimXmlOps.y.orig	2008-08-14 02:24:54.000000000 +0200
+++ cimXmlOps.y	2009-01-16 21:02:32.000000000 +0100
@@ -43,6 +43,10 @@
 #define YYLEX_PARAM parm
 #define YYERROR_VERBOSE 1
 
+/* Maximum size for valueList and valueRefList */
+
+#define MAX_LIST_SIZE 512
+
 extern int yyerror(char*);
 extern int yylex (void *lvalp, ParserControl *parm);
 
@@ -2656,15 +2660,19 @@
         value
         {
           $$.next=1;
-          $$.max=64;
-          $$.values=(XtokValue*)malloc(sizeof(XtokValue)*64);
+          $$.max=MAX_LIST_SIZE;
+          $$.values=(XtokValue*)malloc(sizeof(XtokValue)*$$.max);
           $$.values[0]=$1;
         }
         | valueList value
         {
+	  if ($$.next >= $$.max)
+	    yyerror("Too many values in valueList");
+	  else {
           $$.values[$$.next]=$2;
           $$.next++;
         }
+        }
 ;
 
 valueReference
@@ -2696,15 +2704,19 @@
     : valueReference
     {
        $$.next=1;
-       $$.max=64;
-       $$.values=(XtokValueReference*)malloc(sizeof(XtokValueReference)*64);
+       $$.max=MAX_LIST_SIZE;
+       $$.values=(XtokValueReference*)malloc(sizeof(XtokValueReference)*$$.max);
        $$.values[0]=$1;
     }
     | valueRefList valueReference
     {
+       if ($$.next >= $$.max)
+         yyerror("Too many values in valueRefList");
+       else {
        $$.values[$$.next]=$2;
        $$.next++;
     }
+    }
 ;
 
 boolValue
@@ -2745,8 +2757,8 @@
     : keyBinding
     {
        $$.next=1;
-       $$.max=16;
-       $$.keyBindings=(XtokKeyBinding*)calloc(16,sizeof(XtokKeyBinding));
+       $$.max=32;
+       $$.keyBindings=(XtokKeyBinding*)calloc($$.max,sizeof(XtokKeyBinding));
        $$.keyBindings[0].name=$1.name;
        $$.keyBindings[0].value=$1.value;
        $$.keyBindings[0].type=$1.type;
@@ -2754,12 +2766,16 @@
     }
     | keyBindings keyBinding
     {
+       if ($$.next >= $$.max)
+         yyerror("Too many keyBindings");
+       else {
        $$.keyBindings[$$.next].name=$2.name;
        $$.keyBindings[$$.next].value=$2.value;
        $$.keyBindings[$$.next].type=$2.type;
        $$.keyBindings[$$.next].ref=$2.ref;
        $$.next++;
     }
+    }
 ;
 
 keyBinding
openSUSE Build Service is sponsored by