--- parser3/src/main/pa_exec.C 2016/11/28 22:42:58 1.89 +++ parser3/src/main/pa_exec.C 2023/09/26 20:49:10 1.97 @@ -1,8 +1,8 @@ /** @file Parser: program executing for different OS-es. - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian @todo setrlimit */ @@ -13,7 +13,7 @@ #include "pa_exception.h" #include "pa_common.h" -volatile const char * IDENT_PA_EXEC_C="$Id: pa_exec.C,v 1.89 2016/11/28 22:42:58 moko Exp $" IDENT_PA_EXEC_H; +volatile const char * IDENT_PA_EXEC_C="$Id: pa_exec.C,v 1.97 2023/09/26 20:49:10 moko Exp $" IDENT_PA_EXEC_H; #ifdef _MSC_VER @@ -79,7 +79,7 @@ static DWORD CreateHiddenConsoleProcess( // calculating script's directory char dir[MAX_STRING]; - strncpy(dir, szScriptFileSpec, MAX_STRING-1); dir[MAX_STRING-1]=0; + pa_strncpy(dir, szScriptFileSpec, MAX_STRING); lsplit(dir,' '); // trim arguments rsplit(dir,'/'); rsplit(dir,'\\'); // trim filename @@ -167,7 +167,7 @@ static void read_pipe(File_read_result& static const char* buildCommand(const char* file_spec_cstr, const ArrayString& argv) { const char* result=file_spec_cstr; - if(FILE *f=fopen(file_spec_cstr, "r")) { + if(FILE *f=pa_fopen(file_spec_cstr, "r")) { try { char buf[MAX_STRING]; size_t size=fread(buf, 1, MAX_STRING-1, f); @@ -283,7 +283,7 @@ static pid_t execve_piped(const char* fi // chdir to script's directory char dir[MAX_STRING]; - strncpy(dir, file_spec_cstr, MAX_STRING-1); dir[MAX_STRING-1]=0; + pa_strncpy(dir, file_spec_cstr, MAX_STRING); rsplit(dir,'/'); // trim filename chdir(dir); @@ -313,7 +313,7 @@ static pid_t execve_piped(const char* fi } static int get_exit_status(int pid) { - int status; + int status=0; pid_t cid; while ((cid=waitpid(pid, &status, WUNTRACED)) == -1 && errno == EINTR); if(!cid) @@ -335,7 +335,7 @@ static void read_pipe(String& result, in static void read_pipe(File_read_result& result, int file){ char *buf=(char*)pa_malloc(MAX_STRING+1); - ssize_t bufsize = MAX_STRING; + size_t bufsize = MAX_STRING; result.headers = 0; result.length = 0; @@ -442,7 +442,7 @@ PA_exec_result pa_exec(bool forced_allow if(!forced_allow) { struct stat finfo; - if(stat(file_spec_cstr, &finfo)!=0) + if(pa_stat(file_spec_cstr, &finfo)!=0) throw Exception("file.missing", &file_spec, "stat failed: %s (%d), actual filename '%s'", strerror(errno), errno, file_spec_cstr); check_safe_mode(finfo, file_spec, file_spec_cstr);