text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE127_Buffer_Underread__wchar_t_declare_ncpy_82_bad.cpp
  Label Definition File: CWE127_Buffer_Underread.stack.label.xml
  Template File: sources-sink-82_bad.tmpl.cpp
  */
  /*
   * @description
   * CWE: 127 Buffer Under-read
   * BadSource:  Set data pointer to before the allocated memory buffer
   * GoodSource: Set data pointer to the allocated memory buffer
   * Sinks: ncpy
   *    BadSink : Copy data to string using wcsncpy
   * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer
   *
   * */
  #ifndef OMITBAD
  
  #include "std_testcase.h"
  #include "CWE127_Buffer_Underread__wchar_t_declare_ncpy_82.h"
  
  namespace CWE127_Buffer_Underread__wchar_t_declare_ncpy_82
  {
  
  void CWE127_Buffer_Underread__wchar_t_declare_ncpy_82_bad::action(wchar_t * data)
  {
      {
          wchar_t dest[100];
          wmemset(dest, L'C', 100-1); /* fill with 'C's */
          dest[100-1] = L'\0'; /* null terminate */
          /* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */
          wcsncpy(dest, data, wcslen(dest));
          /* Ensure null termination */
          dest[100-1] = L'\0';
          printWLine(dest);
      }
  }
  
  }
  #endif /* OMITBAD */
  