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

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

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

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