Skip to content

Commit 6905581

Browse files
committed
fuzzers: make printf formatters cross-platform compatible
The `printf` formatters in our standalone fuzzing driver are currently using the "%m" specifier, which is a GNU extension that prints the error message for the error code in `errno`. As we're using libgit2 functions in both cases anyway, let's just use `git_error_last` instead to make this valid on all platforms.
1 parent 48d5632 commit 6905581

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fuzzers/standalone_driver.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static int run_one_file(const char *filename)
2424
int error = 0;
2525

2626
if (git_futils_readbuffer(&buf, filename) < 0) {
27-
fprintf(stderr, "Failed to read %s: %m\n", filename);
27+
fprintf(stderr, "Failed to read %s: %s\n", filename, git_error_last()->message);
2828
error = -1;
2929
goto exit;
3030
}
@@ -57,7 +57,8 @@ int main(int argc, char **argv)
5757
LLVMFuzzerInitialize(&argc, &argv);
5858

5959
if (git_path_dirload(&corpus_files, argv[1], 0, 0x0) < 0) {
60-
fprintf(stderr, "Failed to scan corpus directory: %m\n");
60+
fprintf(stderr, "Failed to scan corpus directory '%s': %s\n",
61+
argv[1], git_error_last()->message);
6162
error = -1;
6263
goto exit;
6364
}

0 commit comments

Comments
 (0)