mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-26 04:02:09 +01:00
Merge branch 'more-fuzzing' into 'master'
fuzzing: Add more fuzzing tests for various string parsing functions See merge request GNOME/glib!1784
This commit is contained in:
commit
ec330e50cf
19
fuzzing/fuzz_date_parse.c
Normal file
19
fuzzing/fuzz_date_parse.c
Normal file
@ -0,0 +1,19 @@
|
||||
#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() doesn’t 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;
|
||||
}
|
25
fuzzing/fuzz_date_time_new_from_iso8601.c
Normal file
25
fuzzing/fuzz_date_time_new_from_iso8601.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "fuzz.h"
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
|
||||
{
|
||||
unsigned char *nul_terminated_data = NULL;
|
||||
GDateTime *dt = NULL;
|
||||
|
||||
fuzz_set_logging_func ();
|
||||
|
||||
/* ignore @size (the function doesn’t support it); ensure @data is nul-terminated */
|
||||
nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size);
|
||||
dt = g_date_time_new_from_iso8601 ((const gchar *) nul_terminated_data, NULL);
|
||||
g_free (nul_terminated_data);
|
||||
|
||||
if (dt != NULL)
|
||||
{
|
||||
gchar *text = g_date_time_format_iso8601 (dt);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
g_clear_pointer (&dt, g_date_time_unref);
|
||||
|
||||
return 0;
|
||||
}
|
25
fuzzing/fuzz_inet_address_mask_new_from_string.c
Normal file
25
fuzzing/fuzz_inet_address_mask_new_from_string.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "fuzz.h"
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
|
||||
{
|
||||
unsigned char *nul_terminated_data = NULL;
|
||||
GInetAddressMask *mask = NULL;
|
||||
|
||||
fuzz_set_logging_func ();
|
||||
|
||||
/* ignore @size (the function doesn’t support it); ensure @data is nul-terminated */
|
||||
nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size);
|
||||
mask = g_inet_address_mask_new_from_string ((const gchar *) nul_terminated_data, NULL);
|
||||
g_free (nul_terminated_data);
|
||||
|
||||
if (mask != NULL)
|
||||
{
|
||||
gchar *text = g_inet_address_mask_to_string (mask);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
g_clear_object (&mask);
|
||||
|
||||
return 0;
|
||||
}
|
25
fuzzing/fuzz_inet_address_new_from_string.c
Normal file
25
fuzzing/fuzz_inet_address_new_from_string.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "fuzz.h"
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
|
||||
{
|
||||
unsigned char *nul_terminated_data = NULL;
|
||||
GInetAddress *addr = NULL;
|
||||
|
||||
fuzz_set_logging_func ();
|
||||
|
||||
/* ignore @size (the function doesn’t support it); ensure @data is nul-terminated */
|
||||
nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size);
|
||||
addr = g_inet_address_new_from_string ((const gchar *) nul_terminated_data);
|
||||
g_free (nul_terminated_data);
|
||||
|
||||
if (addr != NULL)
|
||||
{
|
||||
gchar *text = g_inet_address_to_string (addr);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
g_clear_object (&addr);
|
||||
|
||||
return 0;
|
||||
}
|
25
fuzzing/fuzz_inet_socket_address_new_from_string.c
Normal file
25
fuzzing/fuzz_inet_socket_address_new_from_string.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "fuzz.h"
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
|
||||
{
|
||||
unsigned char *nul_terminated_data = NULL;
|
||||
GSocketAddress *addr = NULL;
|
||||
|
||||
fuzz_set_logging_func ();
|
||||
|
||||
/* ignore @size (the function doesn’t support it); ensure @data is nul-terminated */
|
||||
nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size);
|
||||
addr = g_inet_socket_address_new_from_string ((const gchar *) nul_terminated_data, 1);
|
||||
g_free (nul_terminated_data);
|
||||
|
||||
if (addr != NULL)
|
||||
{
|
||||
gchar *text = g_socket_connectable_to_string (G_SOCKET_CONNECTABLE (addr));
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
g_clear_object (&addr);
|
||||
|
||||
return 0;
|
||||
}
|
25
fuzzing/fuzz_network_address_parse.c
Normal file
25
fuzzing/fuzz_network_address_parse.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "fuzz.h"
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
|
||||
{
|
||||
unsigned char *nul_terminated_data = NULL;
|
||||
GSocketConnectable *connectable = NULL;
|
||||
|
||||
fuzz_set_logging_func ();
|
||||
|
||||
/* ignore @size (g_network_address_parse() doesn’t support it); ensure @data is nul-terminated */
|
||||
nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size);
|
||||
connectable = g_network_address_parse ((const gchar *) nul_terminated_data, 1, NULL);
|
||||
g_free (nul_terminated_data);
|
||||
|
||||
if (connectable != NULL)
|
||||
{
|
||||
gchar *text = g_socket_connectable_to_string (connectable);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
g_clear_object (&connectable);
|
||||
|
||||
return 0;
|
||||
}
|
25
fuzzing/fuzz_network_address_parse_uri.c
Normal file
25
fuzzing/fuzz_network_address_parse_uri.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "fuzz.h"
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
|
||||
{
|
||||
unsigned char *nul_terminated_data = NULL;
|
||||
GSocketConnectable *connectable = NULL;
|
||||
|
||||
fuzz_set_logging_func ();
|
||||
|
||||
/* ignore @size (g_network_address_parse_uri() doesn’t support it); ensure @data is nul-terminated */
|
||||
nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size);
|
||||
connectable = g_network_address_parse_uri ((const gchar *) nul_terminated_data, 1, NULL);
|
||||
g_free (nul_terminated_data);
|
||||
|
||||
if (connectable != NULL)
|
||||
{
|
||||
gchar *text = g_socket_connectable_to_string (connectable);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
g_clear_object (&connectable);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,7 +1,14 @@
|
||||
fuzz_targets = [
|
||||
'fuzz_bookmark',
|
||||
'fuzz_date_parse',
|
||||
'fuzz_date_time_new_from_iso8601',
|
||||
'fuzz_dbus_message',
|
||||
'fuzz_inet_address_mask_new_from_string',
|
||||
'fuzz_inet_address_new_from_string',
|
||||
'fuzz_inet_socket_address_new_from_string',
|
||||
'fuzz_key',
|
||||
'fuzz_network_address_parse',
|
||||
'fuzz_network_address_parse_uri',
|
||||
'fuzz_uri_escape',
|
||||
'fuzz_uri_parse',
|
||||
'fuzz_uri_parse_params',
|
||||
|
Loading…
x
Reference in New Issue
Block a user