--- parser3/src/main/pa_exec.C 2009/10/02 01:18:27 1.78 +++ parser3/src/main/pa_exec.C 2015/10/26 01:21:58 1.85 @@ -1,29 +1,23 @@ /** @file Parser: program executing for different OS-es. - Copyright(c) 2000-2009 ArtLebedev Group(http://www.artlebedev.com) + Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) @todo setrlimit */ -static const char * const IDENT_EXEC_C="$Date: 2009/10/02 01:18:27 $"; - #include "pa_config_includes.h" #include "pa_exec.h" #include "pa_exception.h" #include "pa_common.h" -#ifdef WIN32 -# include -#else -# include -# include -# include -#endif +volatile const char * IDENT_PA_EXEC_C="$Id: pa_exec.C,v 1.85 2015/10/26 01:21:58 moko Exp $" IDENT_PA_EXEC_H; + +#ifdef _MSC_VER -#ifdef WIN32 +#include /// this func from http://www.ccas.ru/~posp/popov/spawn.htm static DWORD CreateHiddenConsoleProcess(LPCTSTR szCmdLine, @@ -339,7 +333,7 @@ static void read_pipe(File_read_result& #ifndef DOXYGEN struct Append_env_pair_info { -#ifdef WIN32 +#ifdef _MSC_VER String::Body& body; Append_env_pair_info(String::Body& abody): body(abody) {} #else @@ -347,10 +341,11 @@ struct Append_env_pair_info { #endif }; #endif + ///@test maybe here and at argv construction --- untaint_cstr(String::L_AS_IS static void append_env_pair(HashStringString::key_type key, HashStringString::value_type value, Append_env_pair_info *info) { -#ifdef WIN32 +#ifdef _MSC_VER info->body << key << "=" << value; info->body.append_know_length("\1", 1); // placeholder for of zero byte #else @@ -362,11 +357,7 @@ static void append_env_pair(HashStringSt } PA_exec_result pa_exec( - bool -#if defined(NO_PA_EXEC) || defined(PA_SAFE_MODE) - forced_allow -#endif - , + bool forced_allow, const String& file_spec, const HashStringString* env, const ArrayString& argv, @@ -380,7 +371,7 @@ PA_exec_result pa_exec( "parser execs are disabled [recompile parser without --disable-execs configure option]"); #endif -#ifdef WIN32 +#ifdef _MSC_VER PROCESS_INFORMATION pi; HANDLE hInWrite, hOutRead, hErrRead; @@ -421,14 +412,10 @@ PA_exec_result pa_exec( CloseHandle(hInWrite); read_pipe(result.out, hOutRead); CloseHandle(hOutRead); - read_pipe(result.err, hErrRead, String::L_TAINTED); + read_pipe(result.err, hErrRead, String::L_TAINTED); CloseHandle(hErrRead); -/* -from http://www.apache.org/websrc/cvsweb.cgi/apache-1.3/src/main/util_script.c?rev=1.151&content-type=text/vnd.viewcvs-markup - - * We must close the handles to the new process and its main thread - * to prevent handle and memory leaks. -*/ + // We must close the handles to the new process and its main thread + // to prevent handle and memory leaks. CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } @@ -440,7 +427,6 @@ from http://www.apache.org/websrc/cvsweb int pipe_write, pipe_read, pipe_err; -#ifdef PA_SAFE_MODE if(!forced_allow) { struct stat finfo; if(stat(file_spec_cstr, &finfo)!=0) @@ -451,7 +437,6 @@ from http://www.apache.org/websrc/cvsweb check_safe_mode(finfo, file_spec, file_spec_cstr); } -#endif char* argv_cstrs[1+100+1]={file_spec_cstr, 0}; const int argv_size=argv.count();