/* goodG2B() - use GoodSource and BadSink */ private static void GoodG2B() { float data; /* FIX: Use a hardcoded number that won't a divide by zero */ data = 2.0f; Dictionary <int, float> dataDictionary = new Dictionary <int, float>(); dataDictionary.Add(0, data); dataDictionary.Add(1, data); dataDictionary.Add(2, data); CWE369_Divide_by_Zero__float_random_modulo_74b.GoodG2BSink(dataDictionary); }
/* goodB2G() - use BadSource and GoodSink */ private static void GoodB2G() { float data; /* POTENTIAL FLAW: Set data to a random value between 0.0f (inclusive) and 1.0f (exclusive) */ Random rand = new Random(); data = (float)rand.NextDouble(); Dictionary <int, float> dataDictionary = new Dictionary <int, float>(); dataDictionary.Add(0, data); dataDictionary.Add(1, data); dataDictionary.Add(2, data); CWE369_Divide_by_Zero__float_random_modulo_74b.GoodB2GSink(dataDictionary); }