text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE176_Improper_Handling_of_Unicode_Encoding__w32_62b.cpp
  Label Definition File: CWE176_Improper_Handling_of_Unicode_Encoding__w32.label.xml
  Template File: sources-sinks-62b.tmpl.cpp
  */
  /*
   * @description
   * CWE: 176 Improper Handling of Unicode Encoding
   * BadSource:  Initialize data as a large unicode string
   * GoodSource: Initialize data as a small unicode string
   * Sinks:
   *    GoodSink: Ensure the array index is valid
   *    BadSink : Improperly check the array index by not checking the upper bound
   * Flow Variant: 62 Data flow: data flows using a C++ reference from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #include <windows.h>
  #include <stdio.h>
  #include <wchar.h>
  #include <string.h>
  #pragma comment( lib, "advapi32" )
  
  namespace CWE176_Improper_Handling_of_Unicode_Encoding__w32_62
  {
  
  #ifndef OMITBAD
  
  void badSource(wchar_t * &data)
  {
      /* POTENTIAL FLAW: Initialize data as a large unicode string that will cause a buffer overflow in the bad sink */
      wcscpy(data, L"\\u9580\\u961c\\u9640\\u963f\\u963b\\u9644\\u9580\\u961c\\u9640\\u963f\\u963b\\u9644");
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B() uses the GoodSource with the BadSink */
  void goodG2BSource(wchar_t * &data)
  {
      /* FIX: Initialize data as a small unicode string that will NOT cause a buffer overflow in the bad sink */
      wcscpy(data, L"\\u9580");
  }
  
  /* goodB2G() uses the BadSource with the GoodSink */
  void goodB2GSource(wchar_t * &data)
  {
      /* POTENTIAL FLAW: Initialize data as a large unicode string that will cause a buffer overflow in the bad sink */
      wcscpy(data, L"\\u9580\\u961c\\u9640\\u963f\\u963b\\u9644\\u9580\\u961c\\u9640\\u963f\\u963b\\u9644");
  }
  
  #endif /* OMITGOOD */
  
  } /* close namespace */
  