From 2b78a26d9dbeb7823c5a3487bfa2535fb4b274bf Mon Sep 17 00:00:00 2001 From: Timotej Kapus Date: Thu, 24 Oct 2019 14:49:07 +0100 Subject: [klee-replay] Fix relative executable paths --- tools/klee-replay/klee-replay.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/klee-replay/klee-replay.c b/tools/klee-replay/klee-replay.c index 1d35079f..efc101b3 100644 --- a/tools/klee-replay/klee-replay.c +++ b/tools/klee-replay/klee-replay.c @@ -321,10 +321,17 @@ int main(int argc, char** argv) { } } + // Executable needs to be converted to an absolute path, as klee-replay calls + // chdir just before executing it + char executable[PATH_MAX]; + if (!realpath(argv[optind], executable)) { + snprintf(executable, PATH_MAX, "KLEE-REPLAY: ERROR: executable %s:", + argv[optind]); + perror(executable); + exit(1); + } /* Normal execution path ... */ - char* executable = argv[optind]; - /* make sure this process has the CAP_SYS_CHROOT capability, if possible. */ #ifdef HAVE_SYS_CAPABILITY_H if (rootdir) @@ -337,14 +344,6 @@ int main(int argc, char** argv) { exit(1); } - /* Verify the executable exists. */ - FILE *f = fopen(executable, "r"); - if (!f) { - fprintf(stderr, "KLEE-REPLAY: ERROR: executable %s not found.\n", executable); - exit(1); - } - fclose(f); - int idx = 0; for (idx = optind + 1; idx != argc; ++idx) { char* input_fname = argv[idx]; -- cgit 1.4.1