about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--tools/klee-replay/klee-replay.c19
1 files 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];