/* goodG2B() - use goodsource and badsink */ private static void GoodG2B(HttpRequest req, HttpResponse resp) { int data = CWE369_Divide_by_Zero__int_Get_Cookies_Web_modulo_61b.GoodG2BSource(req, resp); /* POTENTIAL FLAW: Zero modulus will cause an issue. An integer division will * result in an exception. */ IO.WriteLine("100%" + data + " = " + (100 % data) + "\n"); }
/* goodB2G() - use badsource and goodsink */ private static void GoodB2G(HttpRequest req, HttpResponse resp) { int data = CWE369_Divide_by_Zero__int_Get_Cookies_Web_modulo_61b.GoodB2GSource(req, resp); /* FIX: test for a zero modulus */ if (data != 0) { IO.WriteLine("100%" + data + " = " + (100 % data) + "\n"); } else { IO.WriteLine("This would result in a modulo by zero"); } }