コード例 #1
0
        /* goodB2G1() - use badsource and goodsink by setting the static variable to false instead of true */
        private void GoodB2G1()
        {
            sbyte data = 0;

            /* init data */
            data = 0;
            /* POTENTIAL FLAW: Read data from console with ReadLine*/
            try
            {
                string stringNumber = Console.ReadLine();
                if (stringNumber != null)
                {
                    data = sbyte.Parse(stringNumber.Trim());
                }
            }
            catch (IOException exceptIO)
            {
                IO.Logger.Log(NLog.LogLevel.Warn, "Error with stream reading", exceptIO);
            }
            catch (FormatException exceptNumberFormat)
            {
                IO.Logger.Log(NLog.LogLevel.Warn, "Error with number parsing", exceptNumberFormat);
            }
            goodB2G1PublicStatic = false;
            CWE190_Integer_Overflow__SByte_console_readLine_multiply_22b.GoodB2G1Sink(data);
        }
コード例 #2
0
        /* goodG2B() - use goodsource and badsink */
        private void GoodG2B()
        {
            sbyte data = 0;

            /* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */
            data = 2;
            goodG2BPublicStatic = true;
            CWE190_Integer_Overflow__SByte_console_readLine_multiply_22b.GoodG2BSink(data);
        }