text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE122_Heap_Based_Buffer_Overflow__c_src_char_cpy_61b.c
  Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_src.label.xml
  Template File: sources-sink-61b.tmpl.c
  */
  /*
   * @description
   * CWE: 122 Heap Based Buffer Overflow
   * BadSource:  Initialize data as a large string
   * GoodSource: Initialize data as a small string
   * Sinks: cpy
   *    BadSink : Copy data to string using strcpy
   * Flow Variant: 61 Data flow: data returned from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #include <wchar.h>
  
  #ifndef OMITBAD
  
  char * CWE122_Heap_Based_Buffer_Overflow__c_src_char_cpy_61b_badSource(char * data)
  {
      /* FLAW: Initialize data as a large buffer that is larger than the small buffer used in the sink */
      memset(data, 'A', 100-1); /* fill with 'A's */
      data[100-1] = '\0'; /* null terminate */
      return data;
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B() uses the GoodSource with the BadSink */
  char * CWE122_Heap_Based_Buffer_Overflow__c_src_char_cpy_61b_goodG2BSource(char * data)
  {
      /* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */
      memset(data, 'A', 50-1); /* fill with 'A's */
      data[50-1] = '\0'; /* null terminate */
      return data;
  }
  
  #endif /* OMITGOOD */
  