Ejemplo n.º 1
0
        /* goodB2G() - use badsource and goodsink */
        public static void GoodB2GSink(CWE129_Improper_Validation_of_Array_Index__ReadLine_array_read_check_max_67a.Container dataContainer)
        {
            int data = dataContainer.containerOne;

            /* Need to ensure that the array is of size > 3  and < 101 due to the GoodSource and the large_fixed BadSource */
            int[] array = { 0, 1, 2, 3, 4 };
            /* FIX: Fully verify data before reading from array at location data */
            if (data >= 0 && data < array.Length)
            {
                IO.WriteLine(array[data]);
            }
            else
            {
                IO.WriteLine("Array index out of bounds");
            }
        }
Ejemplo n.º 2
0
        /* goodG2B() - use goodsource and badsink */
        public static void GoodG2BSink(CWE129_Improper_Validation_of_Array_Index__ReadLine_array_read_check_max_67a.Container dataContainer)
        {
            int data = dataContainer.containerOne;

            /* Need to ensure that the array is of size > 3  and < 101 due to the GoodSource and the large_fixed BadSource */
            int[] array = { 0, 1, 2, 3, 4 };
            /* POTENTIAL FLAW: Verify that data < array.Length, but don't verify that data > 0, so may be attempting to read out of the array bounds */
            if (data < array.Length)
            {
                IO.WriteLine(array[data]);
            }
            else
            {
                IO.WriteLine("Array index out of bounds");
            }
        }