/* 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"); StreamReader[] dataArray = new StreamReader[5]; dataArray[2] = data; CWE675_Duplicate_Operations_on_Resource__OpenText_66b.GoodG2BSink(dataArray); }
/* 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(); StreamReader[] dataArray = new StreamReader[5]; dataArray[2] = data; CWE675_Duplicate_Operations_on_Resource__OpenText_66b.GoodB2GSink(dataArray); }
public override void Bad() { StreamReader data; data = File.OpenText(@"BadSource_OpenText.txt"); /* POTENTIAL FLAW: Close the file in the source */ data.Close(); StreamReader[] dataArray = new StreamReader[5]; dataArray[2] = data; CWE675_Duplicate_Operations_on_Resource__OpenText_66b.BadSink(dataArray); }