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

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

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

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