/* goodG2B() - use GoodSource and BadSink */ private static void GoodG2B() { short data; /* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */ data = 2; LinkedList <short> dataLinkedList = new LinkedList <short>(); dataLinkedList.AddLast(data); dataLinkedList.AddLast(data); dataLinkedList.AddLast(data); CWE190_Integer_Overflow__Short_max_add_73b.GoodG2BSink(dataLinkedList); }
/* goodB2G() - use BadSource and GoodSink */ private static void GoodB2G() { short data; /* POTENTIAL FLAW: Use the maximum size of the data type */ data = short.MaxValue; LinkedList <short> dataLinkedList = new LinkedList <short>(); dataLinkedList.AddLast(data); dataLinkedList.AddLast(data); dataLinkedList.AddLast(data); CWE190_Integer_Overflow__Short_max_add_73b.GoodB2GSink(dataLinkedList); }
public override void Bad() { short data; /* POTENTIAL FLAW: Use the maximum size of the data type */ data = short.MaxValue; LinkedList <short> dataLinkedList = new LinkedList <short>(); dataLinkedList.AddLast(data); dataLinkedList.AddLast(data); dataLinkedList.AddLast(data); CWE190_Integer_Overflow__Short_max_add_73b.BadSink(dataLinkedList); }