/* 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"); Container dataContainer = new Container(); dataContainer.containerOne = data; CWE675_Duplicate_Operations_on_Resource__StreamReader_67b.GoodG2BSink(dataContainer); }
/* goodB2G() - use badsource and goodsink */ private static void GoodB2G() { StreamReader data; data = new StreamReader(@"BadSource_OpenText.txt"); /* POTENTIAL FLAW: Close the file in the source */ data.Close(); Container dataContainer = new Container(); dataContainer.containerOne = data; CWE675_Duplicate_Operations_on_Resource__StreamReader_67b.GoodB2GSink(dataContainer); }
public override void Bad() { StreamReader data; data = new StreamReader(@"BadSource_OpenText.txt"); /* POTENTIAL FLAW: Close the file in the source */ data.Close(); Container dataContainer = new Container(); dataContainer.containerOne = data; CWE675_Duplicate_Operations_on_Resource__StreamReader_67b.BadSink(dataContainer); }