[glib: 1/2] fuzzing: Fix assertion failure in fuzz_paths.c




commit c3eb4a939be863b4ce79a657e558395ba0d559f6
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Mar 25 11:23:55 2021 +0000

    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>

 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]