mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-14 16:11:22 +00:00
Prefer the GUID from the firmware than the device
The firmware may be more generic, and it also allows us to match the GUID then doing 'verify' on a device with a different device PID than the firmware actually declares.
This commit is contained in:
parent
a7c99b54ea
commit
40b6b3f597
@ -169,18 +169,26 @@ fu_provider_udev_client_add (FuProviderUdev *provider_udev, GUdevDevice *device)
|
||||
rom_fn, error->message);
|
||||
}
|
||||
version = g_strdup (fu_rom_get_version (rom));
|
||||
|
||||
/* prefer the GUID from the firmware rather than the
|
||||
* hardware as the firmware may be more generic, which
|
||||
* also allows us to match the GUID when doing 'verify'
|
||||
* on a device with a different PID to the firmware */
|
||||
guid_new = g_strdup (fu_rom_get_guid (rom));
|
||||
}
|
||||
|
||||
/* we failed */
|
||||
if (version == NULL)
|
||||
return;
|
||||
|
||||
/* check the guid */
|
||||
if (!fu_guid_is_valid (guid)) {
|
||||
guid_new = fu_guid_generate_from_string (guid);
|
||||
g_debug ("Fixing GUID %s->%s", guid, guid_new);
|
||||
} else {
|
||||
guid_new = g_strdup (guid);
|
||||
/* no GUID from the ROM, so fix up the VID:PID */
|
||||
if (guid_new == NULL) {
|
||||
if (!fu_guid_is_valid (guid)) {
|
||||
guid_new = fu_guid_generate_from_string (guid);
|
||||
g_debug ("Fixing GUID %s->%s", guid, guid_new);
|
||||
} else {
|
||||
guid_new = g_strdup (guid);
|
||||
}
|
||||
}
|
||||
|
||||
/* did we get enough data */
|
||||
|
19
src/fu-rom.c
19
src/fu-rom.c
@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "fu-cleanup.h"
|
||||
#include "fu-guid.h"
|
||||
#include "fu-rom.h"
|
||||
|
||||
static void fu_rom_finalize (GObject *object);
|
||||
@ -68,6 +69,7 @@ struct _FuRomPrivate
|
||||
GInputStream *stream;
|
||||
FuRomKind kind;
|
||||
gchar *version;
|
||||
gchar *guid;
|
||||
guint16 vendor;
|
||||
guint16 model;
|
||||
GPtrArray *hdrs; /* of FuRomPciHeader */
|
||||
@ -631,6 +633,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags,
|
||||
guint number_reads = 0;
|
||||
_cleanup_error_free_ GError *error_local = NULL;
|
||||
_cleanup_free_ gchar *fn = NULL;
|
||||
_cleanup_free_ gchar *id = NULL;
|
||||
_cleanup_free_ guint8 *buffer = NULL;
|
||||
_cleanup_object_unref_ GFileOutputStream *output_stream = NULL;
|
||||
|
||||
@ -817,6 +820,11 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags,
|
||||
g_checksum_update (priv->checksum_wip, hdr->rom_data, hdr->rom_len);
|
||||
}
|
||||
|
||||
/* update guid */
|
||||
id = g_strdup_printf ("0x%04x:0x%04x", priv->vendor, priv->model);
|
||||
priv->guid = fu_guid_generate_from_string (id);
|
||||
g_debug ("using %s for %s", priv->guid, id);
|
||||
|
||||
/* not known */
|
||||
if (priv->version == NULL) {
|
||||
g_set_error_literal (error,
|
||||
@ -849,6 +857,16 @@ fu_rom_get_version (FuRom *rom)
|
||||
return rom->priv->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* fu_rom_get_guid:
|
||||
**/
|
||||
const gchar *
|
||||
fu_rom_get_guid (FuRom *rom)
|
||||
{
|
||||
g_return_val_if_fail (FU_IS_ROM (rom), NULL);
|
||||
return rom->priv->guid;
|
||||
}
|
||||
|
||||
/**
|
||||
* fu_rom_get_vendor:
|
||||
**/
|
||||
@ -914,6 +932,7 @@ fu_rom_finalize (GObject *object)
|
||||
|
||||
g_checksum_free (priv->checksum_wip);
|
||||
g_free (priv->version);
|
||||
g_free (priv->guid);
|
||||
g_ptr_array_unref (priv->hdrs);
|
||||
if (priv->stream != NULL)
|
||||
g_object_unref (priv->stream);
|
||||
|
@ -79,6 +79,7 @@ gboolean fu_rom_extract_all (FuRom *rom,
|
||||
FuRomKind fu_rom_get_kind (FuRom *rom);
|
||||
const gchar *fu_rom_get_version (FuRom *rom);
|
||||
const gchar *fu_rom_get_checksum (FuRom *rom);
|
||||
const gchar *fu_rom_get_guid (FuRom *rom);
|
||||
guint16 fu_rom_get_vendor (FuRom *rom);
|
||||
guint16 fu_rom_get_model (FuRom *rom);
|
||||
const gchar *fu_rom_kind_to_string (FuRomKind kind);
|
||||
|
@ -876,7 +876,6 @@ fu_util_verify_update (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
as_store_set_api_version (store, 0.9);
|
||||
for (i = 1; values[i] != NULL; i++) {
|
||||
_cleanup_free_ gchar *guid = NULL;
|
||||
_cleanup_free_ gchar *id = NULL;
|
||||
_cleanup_object_unref_ AsApp *app = NULL;
|
||||
_cleanup_object_unref_ AsRelease *rel = NULL;
|
||||
_cleanup_object_unref_ FuRom *rom = NULL;
|
||||
@ -894,11 +893,7 @@ fu_util_verify_update (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
|
||||
/* add app to store */
|
||||
app = as_app_new ();
|
||||
id = g_strdup_printf ("0x%04x:0x%04x",
|
||||
fu_rom_get_vendor (rom),
|
||||
fu_rom_get_model (rom));
|
||||
guid = fu_guid_generate_from_string (id);
|
||||
as_app_set_id (app, guid, -1);
|
||||
as_app_set_id (app, fu_rom_get_guid (rom), -1);
|
||||
as_app_set_id_kind (app, AS_ID_KIND_FIRMWARE);
|
||||
as_app_set_source_kind (app, AS_APP_SOURCE_KIND_INF);
|
||||
rel = as_release_new ();
|
||||
|
Loading…
Reference in New Issue
Block a user