text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE23_Relative_Path_Traversal__char_environment_ifstream_54d.cpp
  Label Definition File: CWE23_Relative_Path_Traversal.label.xml
  Template File: sources-sink-54d.tmpl.cpp
  */
  /*
   * @description
   * CWE: 23 Relative Path Traversal
   * BadSource: environment Read input from an environment variable
   * GoodSource: Use a fixed file name
   * Sink: ifstream
   *    BadSink : Open the file named in data using ifstream::open()
   * Flow Variant: 54 Data flow: data passed as an argument from one function through three others to a fifth; all five functions are in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #ifdef _WIN32
  #define BASEPATH "c:\\temp\\"
  #else
  #include <wchar.h>
  #define BASEPATH "/tmp/"
  #endif
  
  #define ENV_VARIABLE "ADD"
  
  #ifdef _WIN32
  #define GETENV getenv
  #else
  #define GETENV getenv
  #endif
  
  #include <fstream>
  using namespace std;
  
  namespace CWE23_Relative_Path_Traversal__char_environment_ifstream_54
  {
  
  /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
  
  #ifndef OMITBAD
  
  /* bad function declaration */
  void badSink_e(char * data);
  
  void badSink_d(char * data)
  {
      badSink_e(data);
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void goodG2BSink_e(char * data);
  
  void goodG2BSink_d(char * data)
  {
      goodG2BSink_e(data);
  }
  
  #endif /* OMITGOOD */
  
  } /* close namespace */
  