Example #1
0
        /* goodG2B() - use goodsource and badsink */
        public static void GoodG2BSink(CWE369_Divide_by_Zero__float_Environment_divide_67a.Container dataContainer)
        {
            float data = dataContainer.containerOne;
            /* POTENTIAL FLAW: Possibly divide by zero */
            int result = (int)(100.0 / data);

            IO.WriteLine(result);
        }
Example #2
0
        /* goodB2G() - use badsource and goodsink */
        public static void GoodB2GSink(CWE369_Divide_by_Zero__float_Environment_divide_67a.Container dataContainer)
        {
            float data = dataContainer.containerOne;

            /* FIX: Check for value of or near zero before dividing */
            if (Math.Abs(data) > 0.000001)
            {
                int result = (int)(100.0 / data);
                IO.WriteLine(result);
            }
            else
            {
                IO.WriteLine("This would result in a divide by zero");
            }
        }