Exemple #1
0
        /* goodB2G() - use badsource and goodsink */
        private void GoodB2G()
        {
            long data;

            /* init data */
            data = 0;
            /* POTENTIAL FLAW: Read data from console with ReadLine*/
            try
            {
                string stringNumber = Console.ReadLine();
                if (stringNumber != null)
                {
                    data = long.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);
            }
            CWE190_Integer_Overflow__Long_console_readLine_add_52b.GoodB2GSink(data);
        }
Exemple #2
0
        /* goodG2B() - use goodsource and badsink */
        private void GoodG2B()
        {
            long data;

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