text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE134_Uncontrolled_Format_String__char_fromFile_fprintf_64b.c
  Label Definition File: CWE134_Uncontrolled_Format_String.label.xml
  Template File: sources-sinks-64b.tmpl.c
  */
  /*
   * @description
   * CWE: 134 Uncontrolled Format String
   * BadSource: fromFile Read input from a file
   * GoodSource: Copy a fixed string into data
   * Sinks: fprintf
   *    GoodSink: fprintf with "%s" as the second argument and data as the third
   *    BadSink : fprintf with data as the second argument
   * Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #ifdef _WIN32
  # define FOPEN fopen
  #else
  /* fopen is used on unix-based OSs */
  # define FOPEN fopen
  #endif
  
  #ifndef OMITBAD
  
  void CWE134_Uncontrolled_Format_String__char_fromFile_fprintf_64b_bad_sink(void * void_data_ptr)
  {
      /* cast void pointer to a pointer of the appropriate type */
      char * * data_ptr = (char * *)void_data_ptr;
      /* dereference data_ptr into data */
      char * data = (*data_ptr);
      /* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
      fprintf(stdout, data);
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE134_Uncontrolled_Format_String__char_fromFile_fprintf_64b_goodG2B_sink(void * void_data_ptr)
  {
      /* cast void pointer to a pointer of the appropriate type */
      char * * data_ptr = (char * *)void_data_ptr;
      /* dereference data_ptr into data */
      char * data = (*data_ptr);
      /* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
      fprintf(stdout, data);
  }
  
  /* goodB2G uses the BadSource with the GoodSink */
  void CWE134_Uncontrolled_Format_String__char_fromFile_fprintf_64b_goodB2G_sink(void * void_data_ptr)
  {
      /* cast void pointer to a pointer of the appropriate type */
      char * * data_ptr = (char * *)void_data_ptr;
      /* dereference data_ptr into data */
      char * data = (*data_ptr);
      /* FIX: Specify the format disallowing a format string vulnerability */
      fprintf(stdout, "%s\n", data);
  }
  
  #endif /* OMITGOOD */
  