text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_wchar_t_ncpy_82_bad.cpp
  Label Definition File: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193.label.xml
  Template File: sources-sink-82_bad.tmpl.cpp
  */
  /*
   * @description
   * CWE: 122 Heap Based Buffer Overflow
   * BadSource:  Allocate memory for a string, but do not allocate space for NULL terminator
   * GoodSource: Allocate enough memory for a string and the NULL terminator
   * Sinks: ncpy
   *    BadSink : Copy string to data using wcsncpy()
   * Flow Variant: 82 Data flow: data passed in a parameter to a virtual method called via a pointer
   *
   * */
  #ifndef OMITBAD
  
  #include "std_testcase.h"
  #include "CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_wchar_t_ncpy_82.h"
  
  namespace CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_wchar_t_ncpy_82
  {
  
  void CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_wchar_t_ncpy_82_bad::action(wchar_t * data)
  {
      {
          wchar_t source[10+1] = SRC_STRING;
          /* Copy length + 1 to include NUL terminator from source */
          /* POTENTIAL FLAW: data may not have enough space to hold source */
          wcsncpy(data, source, wcslen(source) + 1);
          printWLine(data);
          delete [] data;
      }
  }
  
  }
  #endif /* OMITBAD */
  