text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_memcpy_65b.c
  Label Definition File: CWE121_Stack_Based_Buffer_Overflow__src.string.label.xml
  Template File: sources-sink-65b.tmpl.c
  */
  /*
   * @description
   * CWE: 121 Stack Based Buffer Overflow
   * BadSource:  Initialize data as a large string
   * GoodSource: Initialize data as a small string
   * Sinks: memcpy
   *    BadSink : Copy data to string using memcpy
   * Flow Variant: 65 Data/control flow: data passed as an argument from one function to a function in a different source file called via a function pointer
   *
   * */
  
  #include "std_testcase.h"
  
  #include <wchar.h>
  
  #ifndef OMITBAD
  
  void CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_memcpy_65b_bad_sink(char * data)
  {
      {
          char dest[50] = "";
          /* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */
          memcpy(dest, data, strlen(data)*sizeof(char));
          dest[50-1] = '\0'; /* Ensure the destination buffer is null terminated */
          printLine(data);
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_memcpy_65b_goodG2B_sink(char * data)
  {
      {
          char dest[50] = "";
          /* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */
          memcpy(dest, data, strlen(data)*sizeof(char));
          dest[50-1] = '\0'; /* Ensure the destination buffer is null terminated */
          printLine(data);
      }
  }
  
  #endif /* OMITGOOD */
  