/* 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; Dictionary <int, int> countDictionary = new Dictionary <int, int>(); countDictionary.Add(0, count); countDictionary.Add(1, count); countDictionary.Add(2, count); CWE400_Uncontrolled_Resource_Consumption__max_value_write_74b.GoodG2BSink(countDictionary); }
/* goodB2G() - use BadSource and GoodSink */ private static void GoodB2G() { int count; /* POTENTIAL FLAW: Set count to int.MaxValue */ count = int.MaxValue; Dictionary <int, int> countDictionary = new Dictionary <int, int>(); countDictionary.Add(0, count); countDictionary.Add(1, count); countDictionary.Add(2, count); CWE400_Uncontrolled_Resource_Consumption__max_value_write_74b.GoodB2GSink(countDictionary); }
public override void Bad() { int count; /* POTENTIAL FLAW: Set count to int.MaxValue */ count = int.MaxValue; Dictionary <int, int> countDictionary = new Dictionary <int, int>(); countDictionary.Add(0, count); countDictionary.Add(1, count); countDictionary.Add(2, count); CWE400_Uncontrolled_Resource_Consumption__max_value_write_74b.BadSink(countDictionary); }