fwupd/libfwupdplugin/fu-fuzzer-firmware.c.in
2021-02-08 09:17:03 +00:00

27 lines
624 B
C

/*
* Copyright (C) 2020 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include "config.h"
#include "@INCLUDE@"
int
LLVMFuzzerTestOneInput (const guint8 *data, gsize size)
{
g_autoptr(FuFirmware) firmware = @FIRMWARENEW@ ();
g_autoptr(GBytes) fw = g_bytes_new (data, size);
G_GNUC_UNUSED gboolean ret;
ret = fu_firmware_parse (firmware, fw,
FWUPD_INSTALL_FLAG_NO_SEARCH |
FWUPD_INSTALL_FLAG_IGNORE_VID_PID |
FWUPD_INSTALL_FLAG_IGNORE_CHECKSUM,
NULL);
if (ret) {
g_autofree gchar *str = fu_firmware_to_string (firmware);
g_print ("%s", str);
}
return 0;
}