mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-05 02:09:25 +00:00
uefi: Do not add devices with invalid GUIDs
Note: We deliberately don't add the device without 'UPDATABLE' as there's nothing the user can actually do to repair this themselves.
This commit is contained in:
parent
4badf7e963
commit
a0da340b60
@ -726,7 +726,12 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
|
||||
/* add each device */
|
||||
for (guint i = 0; i < entries->len; i++) {
|
||||
const gchar *path = g_ptr_array_index (entries, i);
|
||||
g_autoptr(FuUefiDevice) dev = fu_uefi_device_new_from_entry (path);
|
||||
g_autoptr(GError) error_parse = NULL;
|
||||
g_autoptr(FuUefiDevice) dev = fu_uefi_device_new_from_entry (path, &error_parse);
|
||||
if (dev == NULL) {
|
||||
g_warning ("failed to add %s: %s", path, error_parse->message);
|
||||
continue;
|
||||
}
|
||||
fu_device_set_quirks (FU_DEVICE (dev), fu_plugin_get_quirks (plugin));
|
||||
if (!fu_plugin_uefi_coldplug_device (plugin, dev, error))
|
||||
return FALSE;
|
||||
|
@ -85,11 +85,13 @@ fu_uefi_device_func (void)
|
||||
{
|
||||
g_autofree gchar *fn = NULL;
|
||||
g_autoptr(FuUefiDevice) dev = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
fn = fu_test_get_filename (TESTDATADIR, "efi/esrt/entries/entry0");
|
||||
g_assert (fn != NULL);
|
||||
dev = fu_uefi_device_new_from_entry (fn);
|
||||
dev = fu_uefi_device_new_from_entry (fn, &error);
|
||||
g_assert_nonnull (dev);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_assert_cmpint (fu_uefi_device_get_kind (dev), ==, FU_UEFI_DEVICE_KIND_SYSTEM_FIRMWARE);
|
||||
g_assert_cmpstr (fu_uefi_device_get_guid (dev), ==, "ddc0ee61-e7f0-4e7d-acc5-c070a398838e");
|
||||
@ -184,7 +186,12 @@ fu_uefi_plugin_func (void)
|
||||
devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||
for (guint i = 0; i < entries->len; i++) {
|
||||
const gchar *path = g_ptr_array_index (entries, i);
|
||||
g_autoptr(FuUefiDevice) dev_tmp = fu_uefi_device_new_from_entry (path);
|
||||
g_autoptr(GError) error_local = NULL;
|
||||
g_autoptr(FuUefiDevice) dev_tmp = fu_uefi_device_new_from_entry (path, &error_local);
|
||||
if (dev_tmp == NULL) {
|
||||
g_debug ("failed to add %s: %s", path, error_local->message);
|
||||
continue;
|
||||
}
|
||||
g_ptr_array_add (devices, g_object_ref (dev_tmp));
|
||||
}
|
||||
g_assert_cmpint (devices->len, ==, 2);
|
||||
@ -220,7 +227,8 @@ fu_uefi_update_info_func (void)
|
||||
|
||||
fn = fu_test_get_filename (TESTDATADIR, "efi/esrt/entries/entry0");
|
||||
g_assert (fn != NULL);
|
||||
dev = fu_uefi_device_new_from_entry (fn);
|
||||
dev = fu_uefi_device_new_from_entry (fn, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_nonnull (dev);
|
||||
g_assert_cmpint (fu_uefi_device_get_kind (dev), ==, FU_UEFI_DEVICE_KIND_SYSTEM_FIRMWARE);
|
||||
g_assert_cmpstr (fu_uefi_device_get_guid (dev), ==, "ddc0ee61-e7f0-4e7d-acc5-c070a398838e");
|
||||
|
@ -449,9 +449,9 @@ fu_uefi_device_class_init (FuUefiDeviceClass *klass)
|
||||
}
|
||||
|
||||
FuUefiDevice *
|
||||
fu_uefi_device_new_from_entry (const gchar *entry_path)
|
||||
fu_uefi_device_new_from_entry (const gchar *entry_path, GError **error)
|
||||
{
|
||||
FuUefiDevice *self;
|
||||
g_autoptr(FuUefiDevice) self = NULL;
|
||||
g_autofree gchar *fw_class_fn = NULL;
|
||||
g_autofree gchar *id = NULL;
|
||||
|
||||
@ -481,7 +481,16 @@ fu_uefi_device_new_from_entry (const gchar *entry_path)
|
||||
self->fw_class, self->fmp_hardware_instance);
|
||||
fu_device_set_id (FU_DEVICE (self), id);
|
||||
|
||||
return self;
|
||||
/* this is invalid */
|
||||
if (!fu_common_guid_is_valid (self->fw_class)) {
|
||||
g_set_error (error,
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_NOT_SUPPORTED,
|
||||
"ESRT GUID '%s' was not valid", self->fw_class);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_steal_pointer (&self);
|
||||
}
|
||||
|
||||
FuUefiDevice *
|
||||
|
@ -40,7 +40,8 @@ typedef enum {
|
||||
} FuUefiDeviceStatus;
|
||||
|
||||
FuUefiDevice *fu_uefi_device_new_from_guid (const gchar *guid);
|
||||
FuUefiDevice *fu_uefi_device_new_from_entry (const gchar *entry_path);
|
||||
FuUefiDevice *fu_uefi_device_new_from_entry (const gchar *entry_path,
|
||||
GError **error);
|
||||
FuUefiDevice *fu_uefi_device_new_from_dev (FuDevice *dev);
|
||||
gboolean fu_uefi_device_clear_status (FuUefiDevice *self,
|
||||
GError **error);
|
||||
|
@ -216,7 +216,13 @@ main (int argc, char *argv[])
|
||||
devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||
for (guint i = 0; i < entries->len; i++) {
|
||||
const gchar *path = g_ptr_array_index (entries, i);
|
||||
g_autoptr(FuUefiDevice) dev = fu_uefi_device_new_from_entry (path);
|
||||
g_autoptr(GError) error_parse = NULL;
|
||||
g_autoptr(FuUefiDevice) dev = fu_uefi_device_new_from_entry (path, &error_parse);
|
||||
if (dev == NULL) {
|
||||
g_warning ("failed to parse %s: %s",
|
||||
path, error_parse->message);
|
||||
continue;
|
||||
}
|
||||
fu_device_set_metadata (FU_DEVICE (dev), "EspPath", esp_path);
|
||||
g_ptr_array_add (devices, g_object_ref (dev));
|
||||
}
|
||||
|
1
plugins/uefi/tests/efi/esrt/entries/entry2/capsule_flags
Symbolic link
1
plugins/uefi/tests/efi/esrt/entries/entry2/capsule_flags
Symbolic link
@ -0,0 +1 @@
|
||||
../entry1/capsule_flags
|
1
plugins/uefi/tests/efi/esrt/entries/entry2/fw_class
Normal file
1
plugins/uefi/tests/efi/esrt/entries/entry2/fw_class
Normal file
@ -0,0 +1 @@
|
||||
00000000-0000-0000-0000-000000000000
|
1
plugins/uefi/tests/efi/esrt/entries/entry2/fw_type
Symbolic link
1
plugins/uefi/tests/efi/esrt/entries/entry2/fw_type
Symbolic link
@ -0,0 +1 @@
|
||||
../entry1/fw_type
|
1
plugins/uefi/tests/efi/esrt/entries/entry2/fw_version
Symbolic link
1
plugins/uefi/tests/efi/esrt/entries/entry2/fw_version
Symbolic link
@ -0,0 +1 @@
|
||||
../entry1/fw_version
|
1
plugins/uefi/tests/efi/esrt/entries/entry2/last_attempt_status
Symbolic link
1
plugins/uefi/tests/efi/esrt/entries/entry2/last_attempt_status
Symbolic link
@ -0,0 +1 @@
|
||||
../entry1/last_attempt_status
|
1
plugins/uefi/tests/efi/esrt/entries/entry2/last_attempt_version
Symbolic link
1
plugins/uefi/tests/efi/esrt/entries/entry2/last_attempt_version
Symbolic link
@ -0,0 +1 @@
|
||||
../entry1/last_attempt_version
|
@ -0,0 +1 @@
|
||||
../entry1/lowest_supported_fw_version
|
Loading…
Reference in New Issue
Block a user