text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_memmove_81_goodG2B.cpp
  Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.string.label.xml
  Template File: sources-sink-81_goodG2B.tmpl.cpp
  */
  /*
   * @description
   * CWE: 121 Stack Based Buffer Overflow
   * BadSource:  Set data pointer to the bad buffer
   * GoodSource: Set data pointer to the good buffer
   * Sinks: memmove
   *    BadSink : Copy string to data using memmove
   * 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__CWE805_char_declare_memmove_81.h"
  
  namespace CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_memmove_81
  {
  
  void CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_memmove_81_goodG2B::action(char * data) const
  {
      {
          char source[100];
          memset(source, 'C', 100-1); /* fill with 'C's */
          source[100-1] = '\0'; /* null terminate */
          /* POTENTIAL FLAW: Possible buffer overflow if the size of data is less than the length of source */
          memmove(data, source, 100*sizeof(char));
          data[100-1] = '\0'; /* Ensure the destination buffer is null terminated */
          printLine(data);
      }
  }
  
  }
  #endif /* OMITGOOD */
  