Imported Upstream version 2.67.4
[platform/upstream/glib.git] / fuzzing / fuzz_dbus_message.c
1 #include "fuzz.h"
2
3 static const GDBusCapabilityFlags flags = G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING;
4
5 int
6 LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
7 {
8   gssize bytes;
9   GDBusMessage *msg = NULL;
10   guchar *blob = NULL;
11   gsize msg_size;
12
13   fuzz_set_logging_func ();
14
15   bytes = g_dbus_message_bytes_needed ((guchar*) data, size, NULL);
16   if (bytes <= 0)
17     return 0;
18
19   msg = g_dbus_message_new_from_blob ((guchar*) data, size, flags, NULL);
20   if (msg == NULL)
21     return 0;
22
23   blob = g_dbus_message_to_blob (msg, &msg_size, flags, NULL);
24
25   g_free (blob);
26   g_object_unref (msg);
27   return 0;
28 }