text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_ncat_81_goodG2B.cpp
  Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE806.label.xml
  Template File: sources-sink-81_goodG2B.tmpl.cpp
  */
  /*
   * @description
   * CWE: 121 Stack Based Buffer Overflow
   * BadSource:  Initialize data as a large string
   * GoodSource: Initialize data as a small string
   * Sinks: ncat
   *    BadSink : Copy data to string using wcsncat
   * Flow Variant: 81 Data flow: data passed in a parameter to an virtual method called via a reference
   *
   * */
  #ifndef OMITGOOD
  
  #include "std_testcase.h"
  #include "CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_ncat_81.h"
  
  namespace CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_ncat_81
  {
  
  void CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_ncat_81_goodG2B::action(wchar_t * data) const
  {
      {
          wchar_t dest[50] = L"";
          /* POTENTIAL FLAW: Possible buffer overflow if data is larger than sizeof(dest)-wcslen(dest)*/
          wcsncat(dest, data, wcslen(data));
          dest[50-1] = L'\0'; /* Ensure the destination buffer is null terminated */
          printWLine(data);
      }
  }
  
  }
  #endif /* OMITGOOD */
  