/* goodG2B() - use GoodSource and BadSink */ private static void GoodG2B() { StreamReader data; /* FIX: Open, but do not close the file in the source */ data = File.OpenText(@"GoodSource_OpenText.txt"); Hashtable dataHashtable = new Hashtable(5); dataHashtable.Add(0, data); dataHashtable.Add(1, data); dataHashtable.Add(2, data); CWE675_Duplicate_Operations_on_Resource__OpenText_72b.GoodG2BSink(dataHashtable); }
/* goodB2G() - use BadSource and GoodSink */ private static void GoodB2G() { StreamReader data; data = File.OpenText(@"BadSource_OpenText.txt"); /* POTENTIAL FLAW: Close the file in the source */ data.Close(); Hashtable dataHashtable = new Hashtable(5); dataHashtable.Add(0, data); dataHashtable.Add(1, data); dataHashtable.Add(2, data); CWE675_Duplicate_Operations_on_Resource__OpenText_72b.GoodB2GSink(dataHashtable); }