glib/fuzzing/fuzz_date_parse.c
Philip Withnall 105f4a0f39 fuzzing: Add more fuzzing tests for various string parsing functions
There’s no explicit guarantee that any of these functions are safe to
use on untrusted data, but it does no harm to test them.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-08 11:07:43 +00:00

20 lines
506 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;
GDate *date = g_date_new ();
fuzz_set_logging_func ();
/* ignore @size (g_date_set_parse() doesnt support it); ensure @data is nul-terminated */
nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size);
g_date_set_parse (date, (const gchar *) nul_terminated_data);
g_free (nul_terminated_data);
g_date_free (date);
return 0;
}