Пример #1
0
        /* goodG2B() - use goodsource and badsink */
        public static void GoodG2BSink(CWE191_Integer_Underflow__Long_min_sub_67a.Container dataContainer)
        {
            long data = dataContainer.containerOne;
            /* POTENTIAL FLAW: if data == long.MinValue, this will overflow */
            long result = (long)(data - 1);

            IO.WriteLine("result: " + result);
        }
Пример #2
0
        /* goodB2G() - use badsource and goodsink */
        public static void GoodB2GSink(CWE191_Integer_Underflow__Long_min_sub_67a.Container dataContainer)
        {
            long data = dataContainer.containerOne;

            /* FIX: Add a check to prevent an overflow from occurring */
            if (data > long.MinValue)
            {
                long result = (long)(data - 1);
                IO.WriteLine("result: " + result);
            }
            else
            {
                IO.WriteLine("data value is too small to perform subtraction.");
            }
        }