Example #1
0
        /* goodB2G() - use BadSource and GoodSink */
        private static void GoodB2G()
        {
            byte data;

            /* init data */
            data = 0;
            /* POTENTIAL FLAW: Read data from console with ReadLine*/
            try
            {
                string stringNumber = Console.ReadLine();
                if (stringNumber != null)
                {
                    data = byte.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);
            }
            Hashtable dataHashtable = new Hashtable(5);

            dataHashtable.Add(0, data);
            dataHashtable.Add(1, data);
            dataHashtable.Add(2, data);
            CWE191_Integer_Underflow__Byte_console_ReadLine_sub_72b.GoodB2GSink(dataHashtable);
        }
Example #2
0
        /* goodG2B() - use GoodSource and BadSink */
        private static void GoodG2B()
        {
            byte data;

            /* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */
            data = 2;
            Hashtable dataHashtable = new Hashtable(5);

            dataHashtable.Add(0, data);
            dataHashtable.Add(1, data);
            dataHashtable.Add(2, data);
            CWE191_Integer_Underflow__Byte_console_ReadLine_sub_72b.GoodG2BSink(dataHashtable);
        }