text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE190_Integer_Overflow__int_fgets_postinc_65b.c
  Label Definition File: CWE190_Integer_Overflow__int.label.xml
  Template File: sources-sinks-65b.tmpl.c
  */
  /*
   * @description
   * CWE: 190 Integer Overflow
   * BadSource: fgets Read data from the console using fgets()
   * GoodSource: Set data to a small, non-zero number (two)
   * Sinks: increment
   *    GoodSink: Ensure there will not be an overflow before incrementing data
   *    BadSink : Increment data, which can cause an overflow
   * 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"
  
  #define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2)
  
  #ifndef OMITBAD
  
  void CWE190_Integer_Overflow__int_fgets_postinc_65b_badSink(int data)
  {
      {
          /* POTENTIAL FLAW: Incrementing data could cause an overflow */
          data++;
          int result = data;
          printIntLine(result);
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE190_Integer_Overflow__int_fgets_postinc_65b_goodG2BSink(int data)
  {
      {
          /* POTENTIAL FLAW: Incrementing data could cause an overflow */
          data++;
          int result = data;
          printIntLine(result);
      }
  }
  
  /* goodB2G uses the BadSource with the GoodSink */
  void CWE190_Integer_Overflow__int_fgets_postinc_65b_goodB2GSink(int data)
  {
      /* FIX: Add a check to prevent an overflow from occurring */
      if (data < INT_MAX)
      {
          data++;
          int result = data;
          printIntLine(result);
      }
      else
      {
          printLine("data value is too large to perform arithmetic safely.");
      }
  }
  
  #endif /* OMITGOOD */
  