text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_memmove_82_bad.cpp
  Label Definition File: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806.label.xml
  Template File: sources-sink-82_bad.tmpl.cpp
  */
  /*
   * @description
   * CWE: 122 Heap Based Buffer Overflow
   * BadSource:  Initialize data as a large string
   * GoodSource: Initialize data as a small string
   * Sinks: memmove
   *    BadSink : Copy data to string using memmove
   * 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_CWE806_wchar_t_memmove_82.h"
  
  namespace CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_memmove_82
  {
  
  void CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_memmove_82_bad::action(wchar_t * data)
  {
      {
          wchar_t dest[50] = L"";
          /* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */
          memmove(dest, data, wcslen(data)*sizeof(wchar_t));
          dest[50-1] = L'\0'; /* Ensure the destination buffer is null terminated */
          printWLine(data);
          delete [] data;
      }
  }
  
  }
  #endif /* OMITBAD */
  