text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_65b.c
  Label Definition File: CWE134_Uncontrolled_Format_String.label.xml
  Template File: sources-sinks-65b.tmpl.c
  */
  /*
   * @description
   * CWE: 134 Uncontrolled Format String
   * BadSource: environment Read input from an environment variable
   * GoodSource: Copy a fixed string into data
   * Sinks: printf
   *    GoodSink: wprintf with "%s" as the first argument and data as the second
   *    BadSink : wprintf with only data as an argument
   * 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 _WIN32
  #include <wchar.h>
  #endif
  
  #define ENV_VARIABLE L"ADD"
  
  #ifdef _WIN32
  #define GETENV _wgetenv
  #else
  #define GETENV getenv
  #endif
  
  #ifndef OMITBAD
  
  void CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_65b_badSink(wchar_t * data)
  {
      /* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
      wprintf(data);
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_65b_goodG2BSink(wchar_t * data)
  {
      /* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
      wprintf(data);
  }
  
  /* goodB2G uses the BadSource with the GoodSink */
  void CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_65b_goodB2GSink(wchar_t * data)
  {
      /* FIX: Specify the format disallowing a format string vulnerability */
      wprintf(L"%s\n", data);
  }
  
  #endif /* OMITGOOD */
  