/* goodG2B() - use goodsource and badsink */ private static void GoodG2B() { ushort data; /* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */ data = 2; ushort[] dataArray = new ushort[5]; dataArray[2] = data; CWE190_Integer_Overflow__UInt16_max_square_66b.GoodG2BSink(dataArray); }
/* goodB2G() - use badsource and goodsink */ private static void GoodB2G() { ushort data; /* POTENTIAL FLAW: Use the maximum size of the data type */ data = ushort.MaxValue; ushort[] dataArray = new ushort[5]; dataArray[2] = data; CWE190_Integer_Overflow__UInt16_max_square_66b.GoodB2GSink(dataArray); }
public override void Bad() { ushort data; /* POTENTIAL FLAW: Use the maximum size of the data type */ data = ushort.MaxValue; ushort[] dataArray = new ushort[5]; dataArray[2] = data; CWE190_Integer_Overflow__UInt16_max_square_66b.BadSink(dataArray); }