示例#1
0
        /* goodG2B() - use goodsource and badsink */
        private static void GoodG2B()
        {
            sbyte data = CWE190_Integer_Overflow__SByte_max_add_61b.GoodG2BSource();
            /* POTENTIAL FLAW: if data == sbyte.MaxValue, this will overflow */
            sbyte result = (sbyte)(data + 1);

            IO.WriteLine("result: " + result);
        }
示例#2
0
        public override void Bad()
        {
            sbyte data = CWE190_Integer_Overflow__SByte_max_add_61b.BadSource();
            /* POTENTIAL FLAW: if data == sbyte.MaxValue, this will overflow */
            sbyte result = (sbyte)(data + 1);

            IO.WriteLine("result: " + result);
        }
示例#3
0
        /* goodB2G() - use badsource and goodsink */
        private static void GoodB2G()
        {
            sbyte data = CWE190_Integer_Overflow__SByte_max_add_61b.GoodB2GSource();

            /* FIX: Add a check to prevent an overflow from occurring */
            if (data < sbyte.MaxValue)
            {
                sbyte result = (sbyte)(data + 1);
                IO.WriteLine("result: " + result);
            }
            else
            {
                IO.WriteLine("data value is too large to perform addition.");
            }
        }