text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_65b.cpp
  Label Definition File: CWE36_Absolute_Path_Traversal.label.xml
  Template File: sources-sink-65b.tmpl.cpp
  */
  /*
   * @description
   * CWE: 36 Absolute Path Traversal
   * BadSource: file Read input from a file
   * GoodSource: Full path and file name
   * Sinks: fopen
   *    BadSink : Open the file named in data using fopen()
   * Flow Variant: 65 Data/control flow: data passed as an argument from one function to a function in a different source file called via a function pointer
   *
   * */
  
  #include "std_testcase.h"
  
  #ifndef _WIN32
  #include <wchar.h>
  #endif
  
  #ifdef _WIN32
  #define FILENAME "C:\\temp\\file.txt"
  #else
  #define FILENAME "/tmp/file.txt"
  #endif
  
  #ifdef _WIN32
  #define FOPEN _wfopen
  #else
  #define FOPEN fopen
  #endif
  
  namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_65
  {
  
  #ifndef OMITBAD
  
  void badSink(wchar_t * data)
  {
      {
          FILE *pFile = NULL;
          /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
          pFile = FOPEN(data, L"wb+");
          if (pFile != NULL)
          {
              fclose(pFile);
          }
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void goodG2BSink(wchar_t * data)
  {
      {
          FILE *pFile = NULL;
          /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
          pFile = FOPEN(data, L"wb+");
          if (pFile != NULL)
          {
              fclose(pFile);
          }
      }
  }
  
  #endif /* OMITGOOD */
  
  } /* close namespace */
  