summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-app-inf.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-07-03 16:27:31 +0100
committerRichard Hughes <richard@hughsie.com>2015-07-03 17:09:48 +0100
commit680d47fe40a959f447e10b8b52175d3c2b04e3dd (patch)
treec03af3881b118024db91d41b3ca83a63c3e5b073 /libappstream-glib/as-app-inf.c
parent3ba6c79e8e22cc02f93fabf0809294bdf5e59785 (diff)
downloadappstream-glib-680d47fe40a959f447e10b8b52175d3c2b04e3dd.tar.gz
Do not expect the INF ClassGuid to be the ESRT GUID
I misunderstood the role of the ClassGuid for UEFI firmware. It is not supposed to be the ESRT GUID, but instead a generic 'firmware' GUID set by Microsoft. The actual ESRT is set as a FirmwareID registry key only, so learn how to parse the HK section and fix up all the unit tests. As there are .cab files in the wild (cough, ColorHug, cough) that set the device ID as the ClassGuid, fall back to this to maintain compatibility with either method. Many thanks to Mario Limonciello for helping to debug this. See https://msdn.microsoft.com/en-us/library/windows/hardware/ff547502%28v=vs.85%29.aspx for more information.
Diffstat (limited to 'libappstream-glib/as-app-inf.c')
-rw-r--r--libappstream-glib/as-app-inf.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/libappstream-glib/as-app-inf.c b/libappstream-glib/as-app-inf.c
index 2ce16dd..80519e1 100644
--- a/libappstream-glib/as-app-inf.c
+++ b/libappstream-glib/as-app-inf.c
@@ -25,7 +25,8 @@
#include "as-app-private.h"
#include "as-cleanup.h"
#include "as-inf.h"
-//#include "as-utils.h"
+
+#define AS_APP_INF_CLASS_GUID_FIRMWARE "f2e7dd72-6468-4e36-b6f1-6488f42c1b52"
/**
* as_app_parse_inf_sanitize_guid:
@@ -40,7 +41,7 @@ as_app_parse_inf_sanitize_guid (const gchar *guid)
for (i = 0; guid[i] != '\0'; i++) {
if (g_ascii_isalnum (guid[i]) || guid[i] == '-')
- g_string_append_c (id, guid[i]);
+ g_string_append_c (id, g_ascii_tolower (guid[i]));
}
return g_string_free (id, FALSE);
}
@@ -58,6 +59,8 @@ as_app_parse_inf_file (AsApp *app,
guint i;
_cleanup_error_free_ GError *error_local = NULL;
_cleanup_free_ gchar *catalog_basename = NULL;
+ _cleanup_free_ gchar *class_guid = NULL;
+ _cleanup_free_ gchar *class_guid_unsafe = NULL;
_cleanup_free_ gchar *class = NULL;
_cleanup_free_ gchar *comment = NULL;
_cleanup_free_ gchar *filename_full = NULL;
@@ -102,22 +105,39 @@ as_app_parse_inf_file (AsApp *app,
AS_APP_ERROR_INVALID_TYPE,
"Driver class is '%s', not 'Firmware'", class);
return FALSE;
- }
+ }
as_app_set_id_kind (app, AS_ID_KIND_FIRMWARE);
- /* get the GUID */
- guid = g_key_file_get_string (kf, "Version", "ClassGuid", NULL);
- if (guid == NULL) {
+ /* get the Class GUID */
+ class_guid_unsafe = g_key_file_get_string (kf, "Version", "ClassGuid", NULL);
+ if (class_guid_unsafe == NULL) {
g_set_error_literal (error,
AS_APP_ERROR,
AS_APP_ERROR_INVALID_TYPE,
- "Driver ID is missing");
+ "ClassGuid is missing");
return FALSE;
}
-
- /* strip any curley brackets */
- id = as_app_parse_inf_sanitize_guid (guid);
- as_app_set_id (app, id, -1);
+ class_guid = as_app_parse_inf_sanitize_guid (class_guid_unsafe);
+ if (g_strcmp0 (class_guid, AS_APP_INF_CLASS_GUID_FIRMWARE) != 0) {
+ g_debug ("ClassGuid is '%s', not '%s', so using as an ID",
+ class_guid, AS_APP_INF_CLASS_GUID_FIRMWARE);
+ as_app_set_id (app, class_guid, -1);
+ } else {
+ /* get the ESRT GUID */
+ guid = g_key_file_get_string (kf,
+ "Firmware_AddReg",
+ "HKR_FirmwareId",
+ NULL);
+ if (guid == NULL) {
+ g_set_error_literal (error,
+ AS_APP_ERROR,
+ AS_APP_ERROR_INVALID_TYPE,
+ "HKR->FirmwareId missing from [Firmware_AddReg]");
+ return FALSE;
+ }
+ id = as_app_parse_inf_sanitize_guid (guid);
+ as_app_set_id (app, id, -1);
+ }
/* get vendor */
vendor = g_key_file_get_string (kf, "Version", "Provider", NULL);