glib/fuzzing/fuzz_canonicalize_filename.c
Philip Withnall 1140c228ab fuzzing: Add fuzz tests for functions which parse paths
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-03-24 11:16:49 +00:00

20 lines
539 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "fuzz.h"
int
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
{
unsigned char *nul_terminated_data = NULL;
gchar *canonicalized = NULL;
fuzz_set_logging_func ();
/* ignore @size (g_canonicalize_filename() doesnt support it); ensure @data is nul-terminated */
nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size);
canonicalized = g_canonicalize_filename ((const gchar *) nul_terminated_data, "/");
g_free (nul_terminated_data);
g_free (canonicalized);
return 0;
}