text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_int_declare_loop_66b.c
  Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.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: loop
   *    BadSink : Copy int array to data using a loop
   * Flow Variant: 66 Data flow: data passed in an array from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #ifndef OMITBAD
  
  void CWE121_Stack_Based_Buffer_Overflow__CWE805_int_declare_loop_66b_badSink(int * dataArray[])
  {
      /* copy data out of dataArray */
      int * data = dataArray[2];
      {
          int source[100] = {0}; /* fill with 0's */
          {
              size_t i;
              /* POTENTIAL FLAW: Possible buffer overflow if data < 100 */
              for (i = 0; i < 100; i++)
              {
                  data[i] = source[i];
              }
              printIntLine(data[0]);
          }
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE121_Stack_Based_Buffer_Overflow__CWE805_int_declare_loop_66b_goodG2BSink(int * dataArray[])
  {
      int * data = dataArray[2];
      {
          int source[100] = {0}; /* fill with 0's */
          {
              size_t i;
              /* POTENTIAL FLAW: Possible buffer overflow if data < 100 */
              for (i = 0; i < 100; i++)
              {
                  data[i] = source[i];
              }
              printIntLine(data[0]);
          }
      }
  }
  
  #endif /* OMITGOOD */
  