text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE36_Absolute_Path_Traversal__wchar_t_fromFile_open_65b.c
  Label Definition File: CWE36_Absolute_Path_Traversal.label.xml
  Template File: sources-sink-65b.tmpl.c
  */
  /*
   * @description
   * CWE: 36 Absolute Path Traversal
   * BadSource: fromFile Read input from a file
   * GoodSource: Full path and file name
   * Sinks: open
   *    BadSink :
   * 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"
  
  #ifdef _WIN32
  # define FOPEN _wfopen
  #else
  /* fopen is used on unix-based OSs */
  # define FOPEN fopen
  #endif
  
  #ifdef _WIN32
  # define OPEN _wopen
  # define CLOSE _close
  #else
  # define OPEN wopen
  # define CLOSE close
  #endif
  
  #ifndef OMITBAD
  
  void CWE36_Absolute_Path_Traversal__wchar_t_fromFile_open_65b_bad_sink(wchar_t * data)
  {
      {
          int fd;
          /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
          fd = OPEN(data, O_RDWR|O_CREAT, S_IREAD|S_IWRITE);
          if (fd != -1)
          {
              CLOSE(fd);
          }
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE36_Absolute_Path_Traversal__wchar_t_fromFile_open_65b_goodG2B_sink(wchar_t * data)
  {
      {
          int fd;
          /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
          fd = OPEN(data, O_RDWR|O_CREAT, S_IREAD|S_IWRITE);
          if (fd != -1)
          {
              CLOSE(fd);
          }
      }
  }
  
  #endif /* OMITGOOD */
  