]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Reject relative path for test refdir (#2445)
authorGraham Percival <gperciva@tarsnap.com>
Tue, 24 Dec 2024 19:51:50 +0000 (11:51 -0800)
committerGitHub <noreply@github.com>
Tue, 24 Dec 2024 19:51:50 +0000 (11:51 -0800)
test_utils/test_main.c

index ac4d3a078e235aef81482ed6373c2bc0dce9d7a6..a823de14d587d1dfbe3fbed6df5bf466ec62793b 100644 (file)
@@ -4124,6 +4124,19 @@ main(int argc, char **argv)
                strncat(testprg, "\"", testprg_len);
                testprog = testprg;
        }
+
+       /* Sanity check: reject a relative path for refdir. */
+       if (refdir != NULL) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+               /* TODO: probably use PathIsRelative() from <shlwapi.h>. */
+#else
+               if (refdir[0] != '/') {
+                       fprintf(stderr,
+                           "ERROR: Cannot use relative path for refdir\n");
+                       exit(1);
+               }
+#endif
+       }
 #endif
 
 #if !defined(_WIN32) && defined(SIGPIPE)