text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE197_Numeric_Truncation_Error__int_fscanf_to_short_74b.cpp
  Label Definition File: CWE197_Numeric_Truncation_Error__int.label.xml
  Template File: sources-sink-74b.tmpl.cpp
  */
  /*
   * @description
   * CWE: 197 Numeric Truncation Error
   * BadSource: fscanf Read data from the console using fscanf()
   * GoodSource: Less than CHAR_MAX
   * Sinks: to_short
   *    BadSink : Convert data to a short
   * Flow Variant: 74 Data flow: data passed in a map from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  #include <map>
  
  using namespace std;
  
  namespace CWE197_Numeric_Truncation_Error__int_fscanf_to_short_74
  {
  
  #ifndef OMITBAD
  
  void badSink(map<int, int> dataMap)
  {
      /* copy data out of dataMap */
      int data = dataMap[2];
      {
          /* POTENTIAL FLAW: Convert data to a short, possibly causing a truncation error */
          short shortData = (short)data;
          printShortLine(shortData);
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void goodG2BSink(map<int, int> dataMap)
  {
      int data = dataMap[2];
      {
          /* POTENTIAL FLAW: Convert data to a short, possibly causing a truncation error */
          short shortData = (short)data;
          printShortLine(shortData);
      }
  }
  
  #endif /* OMITGOOD */
  
  } /* close namespace */
  