fuzzing: Fix assertion failure in fuzz_paths.c

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 <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2021-03-25 11:23:55 +00:00
parent 55cbc31517
commit c3eb4a939b

View File

@ -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); g_assert (skipped_root == NULL || skipped_root <= (const gchar *) nul_terminated_data + size);
basename = g_path_get_basename ((const gchar *) nul_terminated_data); 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); 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 (nul_terminated_data);
g_free (dirname); g_free (dirname);