/* goodG2B() - use GoodSource and BadSink */ private static void GoodG2B() { int count; /* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */ count = 2; LinkedList <int> countLinkedList = new LinkedList <int>(); countLinkedList.AddLast(count); countLinkedList.AddLast(count); countLinkedList.AddLast(count); CWE400_Uncontrolled_Resource_Consumption__Random_write_73b.GoodG2BSink(countLinkedList); }
/* goodB2G() - use BadSource and GoodSink */ private static void GoodB2G() { int count; /* POTENTIAL FLAW: Set count to a random value */ count = (new Random()).Next(); LinkedList <int> countLinkedList = new LinkedList <int>(); countLinkedList.AddLast(count); countLinkedList.AddLast(count); countLinkedList.AddLast(count); CWE400_Uncontrolled_Resource_Consumption__Random_write_73b.GoodB2GSink(countLinkedList); }
public override void Bad() { int count; /* POTENTIAL FLAW: Set count to a random value */ count = (new Random()).Next(); LinkedList <int> countLinkedList = new LinkedList <int>(); countLinkedList.AddLast(count); countLinkedList.AddLast(count); countLinkedList.AddLast(count); CWE400_Uncontrolled_Resource_Consumption__Random_write_73b.BadSink(countLinkedList); }