text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE124_Buffer_Underwrite__CWE839_fgets_82_goodG2B.cpp
  Label Definition File: CWE124_Buffer_Underwrite__CWE839.label.xml
  Template File: sources-sinks-82_goodG2B.tmpl.cpp
  */
  /*
   * @description
   * CWE: 124 Buffer Underwrite
   * BadSource: fgets Read data from the console using fgets()
   * GoodSource: Non-negative but less than 10
   * Sinks:
   *    GoodSink: Ensure the array index is valid
   *    BadSink : Improperly check the array index by not checking the lower bound
   * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer
   *
   * */
  #ifndef OMITGOOD
  
  #include "std_testcase.h"
  #include "CWE124_Buffer_Underwrite__CWE839_fgets_82.h"
  
  namespace CWE124_Buffer_Underwrite__CWE839_fgets_82
  {
  
  void CWE124_Buffer_Underwrite__CWE839_fgets_82_goodG2B::action(int data)
  {
      {
          int i;
          int buffer[10] = { 0 };
          /* POTENTIAL FLAW: Attempt to access a negative index of the array
          * This code does not check to see if the array index is negative */
          if (data < 10)
          {
              buffer[data] = 1;
              /* Print the array values */
              for(i = 0; i < 10; i++)
              {
                  printIntLine(buffer[i]);
              }
          }
          else
          {
              printLine("ERROR: Array index is negative.");
          }
      }
  }
  
  }
  #endif /* OMITGOOD */
  