/* goodG2B() - use goodsource and badsink */ private void GoodG2B() { StreamReader data = null; /* FIX: Open, but do not close the file in the source */ data = File.OpenText(@"GoodSource_OpenText.txt"); goodG2BPublicStatic = true; CWE675_Duplicate_Operations_on_Resource__OpenText_22b.GoodG2BSink(data); }
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */ private void GoodB2G2() { StreamReader data = null; data = File.OpenText(@"BadSource_OpenText.txt"); /* POTENTIAL FLAW: Close the file in the source */ data.Close(); goodB2G2PublicStatic = true; CWE675_Duplicate_Operations_on_Resource__OpenText_22b.GoodB2G2Sink(data); }
public override void Bad() { StreamReader data = null; data = File.OpenText(@"BadSource_OpenText.txt"); /* POTENTIAL FLAW: Close the file in the source */ data.Close(); badPublicStatic = true; CWE675_Duplicate_Operations_on_Resource__OpenText_22b.BadSink(data); }