text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE36_Absolute_Path_Traversal__wchar_t_console_ifstream_51b.cpp
  Label Definition File: CWE36_Absolute_Path_Traversal.label.xml
  Template File: sources-sink-51b.tmpl.cpp
  */
  /*
   * @description
   * CWE: 36 Absolute Path Traversal
   * BadSource: console Read input from the console
   * GoodSource: Full path and file name
   * Sink: ifstream
   *    BadSink : Open the file named in data using ifstream::open()
   * Flow Variant: 51 Data flow: data passed as an argument from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #ifndef _WIN32
  #include <wchar.h>
  #endif
  
  #include <fstream>
  using namespace std;
  
  namespace CWE36_Absolute_Path_Traversal__wchar_t_console_ifstream_51
  {
  
  /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
  
  #ifndef OMITBAD
  
  void badSink(wchar_t * data)
  {
      {
          ifstream inputFile;
          /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
          inputFile.open((char *)data);
          inputFile.close();
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void goodG2BSink(wchar_t * data)
  {
      {
          ifstream inputFile;
          /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
          inputFile.open((char *)data);
          inputFile.close();
      }
  }
  
  #endif /* OMITGOOD */
  
  } /* close namespace */
  