/* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */ private void GoodB2G2() { short data = 0; /* POTENTIAL FLAW: Use a random value */ data = (short)(new Random().Next(short.MinValue, short.MaxValue)); goodB2G2PublicStatic = true; CWE190_Integer_Overflow__Short_rand_add_22b.GoodB2G2Sink(data); }
/* goodG2B() - use goodsource and badsink */ private void GoodG2B() { short data = 0; /* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */ data = 2; goodG2BPublicStatic = true; CWE190_Integer_Overflow__Short_rand_add_22b.GoodG2BSink(data); }
public override void Bad() { short data = 0; /* POTENTIAL FLAW: Use a random value */ data = (short)(new Random().Next(short.MinValue, short.MaxValue)); badPublicStatic = true; CWE190_Integer_Overflow__Short_rand_add_22b.BadSink(data); }