text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cpy_66b.c
  Label Definition File: CWE121_Stack_Based_Buffer_Overflow__dest.label.xml
  Template File: sources-sink-66b.tmpl.c
  */
  /*
   * @description
   * CWE: 121 Stack Based Buffer Overflow
   * BadSource:  Set data pointer to the bad buffer
   * GoodSource: Set data pointer to the good buffer
   * Sinks: cpy
   *    BadSink : Copy string to data using strcpy
   * Flow Variant: 66 Data flow: data passed in an array from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #include <wchar.h>
  
  #ifndef OMITBAD
  
  void CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cpy_66b_badSink(char * dataArray[])
  {
      /* copy data out of dataArray */
      char * data = dataArray[2];
      {
          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 */
          strcpy(data, source);
          printLine(data);
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cpy_66b_goodG2BSink(char * dataArray[])
  {
      char * data = dataArray[2];
      {
          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 */
          strcpy(data, source);
          printLine(data);
      }
  }
  
  #endif /* OMITGOOD */
  