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