From 84e8d245406ccac3842c452eda7df25c8d6a0a66 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 8 Dec 2020 18:36:33 +0000 Subject: [PATCH] solokey: Prevent a critical warning when parsing invalid JSON data --- plugins/solokey/fu-solokey-firmware.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/solokey/fu-solokey-firmware.c b/plugins/solokey/fu-solokey-firmware.c index e0ee8b984..89fcd0c80 100644 --- a/plugins/solokey/fu-solokey-firmware.c +++ b/plugins/solokey/fu-solokey-firmware.c @@ -55,6 +55,13 @@ fu_solokey_firmware_parse (FuFirmware *firmware, return FALSE; } json_root = json_parser_get_root (parser); + if (json_root == NULL || !JSON_NODE_HOLDS_OBJECT (json_root)) { + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_INVALID_FILE, + "JSON invalid as has no root"); + return FALSE; + } json_obj = json_node_get_object (json_root); if (!json_object_has_member (json_obj, "firmware")) { g_set_error_literal (error,