text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE190_Integer_Overflow__int_fscanf_square_62b.cpp
  Label Definition File: CWE190_Integer_Overflow__int.label.xml
  Template File: sources-sinks-62b.tmpl.cpp
  */
  /*
   * @description
   * CWE: 190 Integer Overflow
   * BadSource: fscanf Read data from the console using fscanf()
   * GoodSource: Set data to a small, non-zero number (two)
   * Sinks: square
   *    GoodSink: Ensure there will not be an overflow before squaring data
   *    BadSink : Square data, which can lead to overflow
   * Flow Variant: 62 Data flow: data flows using a C++ reference from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  namespace CWE190_Integer_Overflow__int_fscanf_square_62
  {
  
  #ifndef OMITBAD
  
  void badSource(int &data)
  {
      /* POTENTIAL FLAW: Read data from the console using fscanf() */
      fscanf(stdin, "%d", &data);
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B() uses the GoodSource with the BadSink */
  void goodG2BSource(int &data)
  {
      /* FIX: Use a small, non-zero value that will not cause an integer overflow in the sinks */
      data = 2;
  }
  
  /* goodB2G() uses the BadSource with the GoodSink */
  void goodB2GSource(int &data)
  {
      /* POTENTIAL FLAW: Read data from the console using fscanf() */
      fscanf(stdin, "%d", &data);
  }
  
  #endif /* OMITGOOD */
  
  } /* close namespace */
  