/* goodG2B() - use goodsource and badsink */ private void GoodG2B() { float data = 0.0f; /* FIX: Use a hardcoded number that won't a divide by zero */ data = 2.0f; goodG2BPublicStatic = true; CWE369_Divide_by_Zero__float_random_divide_22b.GoodG2BSink(data); }
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */ private void GoodB2G2() { float data = 0.0f; /* POTENTIAL FLAW: Set data to a random value between 0.0f (inclusive) and 1.0f (exclusive) */ Random rand = new Random(); data = (float)rand.NextDouble(); goodB2G2PublicStatic = true; CWE369_Divide_by_Zero__float_random_divide_22b.GoodB2G2Sink(data); }
public override void Bad() { float data = 0.0f; /* POTENTIAL FLAW: Set data to a random value between 0.0f (inclusive) and 1.0f (exclusive) */ Random rand = new Random(); data = (float)rand.NextDouble(); badPublicStatic = true; CWE369_Divide_by_Zero__float_random_divide_22b.BadSink(data); }