text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE190_Integer_Overflow__unsigned_int_max_add_65b.c
  Label Definition File: CWE190_Integer_Overflow.label.xml
  Template File: sources-sinks-65b.tmpl.c
  */
  /*
   * @description
   * CWE: 190 Integer Overflow
   * BadSource: max Set data to the max value for unsigned int
   * GoodSource: Set data to a small, non-zero number (two)
   * Sinks: add
   *    GoodSink: Ensure there will not be an overflow before adding 1 to data
   *    BadSink : Add 1 to 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"
  
  #ifndef OMITBAD
  
  void CWE190_Integer_Overflow__unsigned_int_max_add_65b_badSink(unsigned int data)
  {
      {
          /* POTENTIAL FLAW: Adding 1 to data could cause an overflow */
          unsigned int result = data + 1;
          printUnsignedLine(result);
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE190_Integer_Overflow__unsigned_int_max_add_65b_goodG2BSink(unsigned int data)
  {
      {
          /* POTENTIAL FLAW: Adding 1 to data could cause an overflow */
          unsigned int result = data + 1;
          printUnsignedLine(result);
      }
  }
  
  /* goodB2G uses the BadSource with the GoodSink */
  void CWE190_Integer_Overflow__unsigned_int_max_add_65b_goodB2GSink(unsigned int data)
  {
      /* FIX: Add a check to prevent an overflow from occurring */
      if (data < UINT_MAX)
      {
          unsigned int result = data + 1;
          printUnsignedLine(result);
      }
      else
      {
          printLine("data value is too large to perform arithmetic safely.");
      }
  }
  
  #endif /* OMITGOOD */
  