/* 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; Container dataContainer = new Container(); dataContainer.containerOne = data; CWE369_Divide_by_Zero__float_random_divide_67b.GoodG2BSink(dataContainer ); }
/* 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(); Container dataContainer = new Container(); dataContainer.containerOne = data; CWE369_Divide_by_Zero__float_random_divide_67b.GoodB2GSink(dataContainer ); }