From c3eb4a939be863b4ce79a657e558395ba0d559f6 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 25 Mar 2021 11:23:55 +0000 Subject: [PATCH] fuzzing: Fix assertion failure in fuzz_paths.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If operating on a zero-length input, the return values of `g_path_get_basename()` and `g_path_get_dirname()` are correctly `.`. The assertions in the test didn’t account for this. oss-fuzz#32454 Signed-off-by: Philip Withnall --- fuzzing/fuzz_paths.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fuzzing/fuzz_paths.c b/fuzzing/fuzz_paths.c index 1c866445f..fbed84771 100644 --- a/fuzzing/fuzz_paths.c +++ b/fuzzing/fuzz_paths.c @@ -19,10 +19,10 @@ LLVMFuzzerTestOneInput (const unsigned char *data, size_t size) g_assert (skipped_root == NULL || skipped_root <= (const gchar *) nul_terminated_data + size); basename = g_path_get_basename ((const gchar *) nul_terminated_data); - g_assert (strlen (basename) <= size); + g_assert (strcmp (basename, ".") == 0 || strlen (basename) <= size); dirname = g_path_get_dirname ((const gchar *) nul_terminated_data); - g_assert (strlen (dirname) <= size); + g_assert (strcmp (dirname, ".") == 0 || strlen (dirname) <= size); g_free (nul_terminated_data); g_free (dirname);