/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__wchar_t_listen_socket_w32_spawnvp_81_goodG2B.cpp Label Definition File: CWE78_OS_Command_Injection.strings.label.xml Template File: sources-sink-81_goodG2B.tmpl.cpp */ /* * @description * CWE: 78 OS Command Injection * BadSource: listen_socket Read data using a listen socket (server side) * GoodSource: Fixed string * Sinks: w32_spawnvp * BadSink : execute command with wspawnvp * Flow Variant: 81 Data flow: data passed in a parameter to an virtual method called via a reference * * */ #ifndef OMITGOOD #include "std_testcase.h" #include "CWE78_OS_Command_Injection__wchar_t_listen_socket_w32_spawnvp_81.h" #include namespace CWE78_OS_Command_Injection__wchar_t_listen_socket_w32_spawnvp_81 { void CWE78_OS_Command_Injection__wchar_t_listen_socket_w32_spawnvp_81_goodG2B::action(wchar_t * data) const { { wchar_t *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL}; /* wspawnvp - searches for the location of the command among * the directories specified by the PATH environment variable */ /* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */ _wspawnvp(_P_WAIT, COMMAND_INT, args); } } } #endif /* OMITGOOD */