/* goodG2B() - use GoodSource and BadSink */ private static void GoodG2B() { string data; /* FIX: Use a hardcoded int as a string */ data = "5"; Dictionary <int, string> dataDictionary = new Dictionary <int, string>(); dataDictionary.Add(0, data); dataDictionary.Add(1, data); dataDictionary.Add(2, data); CWE606_Unchecked_Loop_Condition__ReadLine_74b.GoodG2BSink(dataDictionary); }
/* goodB2G() - use BadSource and GoodSink */ private static void GoodB2G() { string data; data = ""; /* Initialize data */ { /* read user input from console with ReadLine */ try { /* POTENTIAL FLAW: Read data from the console using ReadLine */ data = Console.ReadLine(); } catch (IOException exceptIO) { IO.Logger.Log(NLog.LogLevel.Warn, exceptIO, "Error with stream reading"); } } Dictionary <int, string> dataDictionary = new Dictionary <int, string>(); dataDictionary.Add(0, data); dataDictionary.Add(1, data); dataDictionary.Add(2, data); CWE606_Unchecked_Loop_Condition__ReadLine_74b.GoodB2GSink(dataDictionary); }