Ejemplo n.º 1
0
        /* goodG2B() - use goodsource and badsink */
        private static void GoodG2B()
        {
            sbyte data = CWE191_Integer_Underflow__SByte_min_sub_61b.GoodG2BSource();
            /* POTENTIAL FLAW: if data == sbyte.MinValue, this will overflow */
            sbyte result = (sbyte)(data - 1);

            IO.WriteLine("result: " + result);
        }
Ejemplo n.º 2
0
        public override void Bad()
        {
            sbyte data = CWE191_Integer_Underflow__SByte_min_sub_61b.BadSource();
            /* POTENTIAL FLAW: if data == sbyte.MinValue, this will overflow */
            sbyte result = (sbyte)(data - 1);

            IO.WriteLine("result: " + result);
        }
Ejemplo n.º 3
0
        /* goodB2G() - use badsource and goodsink */
        private static void GoodB2G()
        {
            sbyte data = CWE191_Integer_Underflow__SByte_min_sub_61b.GoodB2GSource();

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