text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_52c.c
  Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE193.label.xml
  Template File: sources-sink-52c.tmpl.c
  */
  /*
   * @description
   * CWE: 121 Stack Based Buffer Overflow
   * BadSource:  Point data to a buffer that does not have space for a NULL terminator
   * GoodSource: Point data to a buffer that includes space for a NULL terminator
   * Sink: cpy
   *    BadSink : Copy string to data using wcscpy()
   * Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #ifndef _WIN32
  #include <wchar.h>
  #endif
  
  /* MAINTENANCE NOTE: The length of this string should equal the 10 */
  #define SRC_STRING L"AAAAAAAAAA"
  
  /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
  
  #ifndef OMITBAD
  
  void CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_52c_badSink(wchar_t * data)
  {
      {
          wchar_t source[10+1] = SRC_STRING;
          /* POTENTIAL FLAW: data may not have enough space to hold source */
          wcscpy(data, source);
          printWLine(data);
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_52c_goodG2BSink(wchar_t * data)
  {
      {
          wchar_t source[10+1] = SRC_STRING;
          /* POTENTIAL FLAW: data may not have enough space to hold source */
          wcscpy(data, source);
          printWLine(data);
      }
  }
  
  #endif /* OMITGOOD */
  