From a1573835dd4d0845ad534bda75008901187ae93a Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 14 Nov 2021 10:44:47 +0100 Subject: Change ResolvePath behaviour in sync with box86 --- src/main.c | 10 ++-------- src/tools/fileutils.c | 2 +- src/wrapped/wrappedlibc.c | 4 ---- 3 files changed, 3 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 682f4fe6..933cd57f 100755 --- a/src/main.c +++ b/src/main.c @@ -848,10 +848,7 @@ int main(int argc, const char **argv, const char **env) { // check BOX64_LD_LIBRARY_PATH and load it LoadEnvVars(my_context); - if(argv[0][0]=='/') - my_context->box64path = strdup(argv[0]); - else - my_context->box64path = ResolveFile(argv[0], &my_context->box64_path); + my_context->box64path = ResolveFile(argv[0], &my_context->box64_path); // prepare all other env. var my_context->envc = CountEnv(environ?environ:env); printf_log(LOG_INFO, "Counted %d Env var\n", my_context->envc); @@ -893,10 +890,7 @@ int main(int argc, const char **argv, const char **env) { } // lets build argc/argv stuff printf_log(LOG_INFO, "Looking for %s\n", prog); - if(strchr(prog, '/')) - my_context->argv[0] = strdup(prog); - else - my_context->argv[0] = ResolveFile(prog, &my_context->box64_path); + my_context->argv[0] = ResolveFile(prog, &my_context->box64_path); // check if box86 is present { my_context->box86path = strdup(my_context->box64path); diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c index fe927398..5a6c0af8 100755 --- a/src/tools/fileutils.c +++ b/src/tools/fileutils.c @@ -60,7 +60,7 @@ char* ResolveFile(const char* filename, path_collection_t* paths) return realpath(p, NULL); } - return NULL; + return strdup(filename); //NULL; } int FileIsX64ELF(const char* filename) diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 1d9ee570..91bc50b4 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1653,8 +1653,6 @@ EXPORT int32_t my_execvp(x64emu_t* emu, const char* path, char* const argv[]) { // need to use BOX64_PATH / PATH here... char* fullpath = ResolveFile(path, &my_context->box64_path); - if(!fullpath) - fullpath = strdup(path); // use fullpath... int self = isProcSelf(fullpath, "exe"); int x64 = FileIsX64ELF(fullpath); @@ -1705,8 +1703,6 @@ EXPORT int32_t my_execlp(x64emu_t* emu, const char* path) { // need to use BOX64_PATH / PATH here... char* fullpath = ResolveFile(path, &my_context->box64_path); - if(!fullpath) - fullpath = strdup(path); // use fullpath... int self = isProcSelf(fullpath, "exe"); int x64 = FileIsX64ELF(fullpath); -- cgit 1.4.1