text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE134_Uncontrolled_Format_String__char_file_snprintf_54e.c
  Label Definition File: CWE134_Uncontrolled_Format_String.label.xml
  Template File: sources-sinks-54e.tmpl.c
  */
  /*
   * @description
   * CWE: 134 Uncontrolled Format String
   * BadSource: file Read input from a file
   * GoodSource: Copy a fixed string into data
   * Sinks: snprintf
   *    GoodSink: snprintf with "%s" as the third argument and data as the fourth
   *    BadSink : snprintf with data as the third argument
   * Flow Variant: 54 Data flow: data passed as an argument from one function through three others to a fifth; all five functions are in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #ifndef _WIN32
  #include <wchar.h>
  #endif
  
  #ifdef _WIN32
  #define FILENAME "C:\\temp\\file.txt"
  #else
  #define FILENAME "/tmp/file.txt"
  #endif
  
  #ifdef _WIN32
  #define SNPRINTF _snprintf
  #else
  #define SNPRINTF snprintf
  #endif
  
  #ifndef OMITBAD
  
  void CWE134_Uncontrolled_Format_String__char_file_snprintf_54e_badSink(char * data)
  {
      {
          char dest[100] = "";
          /* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
          SNPRINTF(dest, 100-1, data);
          printLine(dest);
      }
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE134_Uncontrolled_Format_String__char_file_snprintf_54e_goodG2BSink(char * data)
  {
      {
          char dest[100] = "";
          /* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
          SNPRINTF(dest, 100-1, data);
          printLine(dest);
      }
  }
  
  /* goodB2G uses the BadSource with the GoodSink */
  void CWE134_Uncontrolled_Format_String__char_file_snprintf_54e_goodB2GSink(char * data)
  {
      {
          char dest[100] = "";
          /* FIX: Specify the format disallowing a format string vulnerability */
          SNPRINTF(dest, 100-1, "%s", data);
          printLine(dest);
      }
  }
  
  #endif /* OMITGOOD */
  