From b4dd5f682b643b3d3405586eaf6125f383e36295 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Thu, 6 Jan 2022 10:24:39 +0100 Subject: [PATCH] fix shacheck for windows --- src/lib/win32/basename.c | 5 +++++ src/util_common.h | 5 +++++ test/shacheck.c | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/lib/win32/basename.c b/src/lib/win32/basename.c index 61ae8a3..1b1c0b1 100644 --- a/src/lib/win32/basename.c +++ b/src/lib/win32/basename.c @@ -5,6 +5,11 @@ char* basename(char* path) { // note this is not a proper basename implementation char *p = strrchr (path, '\\'); + if (p == NULL) + { + // sometimes we pass paths on win with "/" seperators + p = strrchr(path, '/'); + } return p ? p + 1 : (char *) path; // char full_path[MAX_PATH], drive[MAX_PATH], dir[MAX_PATH], filename[MAX_PATH], ext[MAX_PATH]; diff --git a/src/util_common.h b/src/util_common.h index 60d2403..1aad13c 100644 --- a/src/util_common.h +++ b/src/util_common.h @@ -14,4 +14,9 @@ void version(); +#ifdef _WIN32 +// add correct declaration for basename +char* basename(char*); +#endif + #endif diff --git a/test/shacheck.c b/test/shacheck.c index 9954342..9e7ae88 100644 --- a/test/shacheck.c +++ b/test/shacheck.c @@ -59,7 +59,6 @@ int main (int argc, char *argv[]) { char *cmd = untaint(argv[1]); char *outf = argv[2]; char *echecksum = argv[3]; - char **args = calloc(argc-2, sizeof(void*)); args[0] = cmd; @@ -68,7 +67,15 @@ int main (int argc, char *argv[]) { int status; #ifdef _WIN32 - status = system(cmd); + char* fullcmd = malloc(2000); + strcpy(fullcmd, args[0]); + for(int i=1; i