/* goodB2G() - use badsource and goodsink */ private static void GoodB2G() { ushort data; /* init data */ data = 0; /* POTENTIAL FLAW: Read data from console with ReadLine*/ try { string stringNumber = Console.ReadLine(); if (stringNumber != null) { data = ushort.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); } CWE191_Integer_Underflow__UInt16_console_ReadLine_sub_71b.GoodB2GSink((Object)data); }
/* goodG2B() - use goodsource and badsink */ private static void GoodG2B() { ushort data; /* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */ data = 2; CWE191_Integer_Underflow__UInt16_console_ReadLine_sub_71b.GoodG2BSink((Object)data); }