diff --git a/src/adapter.c b/src/adapter.c
index 2bb94cf..f422bba 100644
--- a/src/adapter.c
+++ b/src/adapter.c
str2ba(peer, &info->bdaddr);
info->bdaddr_type = bdaddr_type;
+ /* Fix up address type if it was stored with the wrong
+ * address type since Load Link Keys are only meant to
+ * work with BR/EDR addresses as per MGMT documentation.
+ */
+ if (info->bdaddr_type != BDADDR_BREDR)
+ info->bdaddr_type = BDADDR_BREDR;
+
if (!strncmp(str, "0x", 2))
str2buf(&str[2], info->key, sizeof(info->key));
else
str2ba(peer, <k->bdaddr);
ltk->bdaddr_type = peer_type;
+ /* Fix up address type if it was stored with the wrong
+ * address type since Load Long Term Keys are only meant
+ * to work with LE addresses as per MGMT documentation.
+ */
+ if (ltk->bdaddr_type == BDADDR_BREDR)
+ ltk->bdaddr_type = BDADDR_LE_PUBLIC;
+
/*
* Long term keys should respond to an identity address which can
* either be a public address or a random static address. Keys
struct irk_info *irk = NULL;
char *str;
- str = g_key_file_get_string(key_file, "IdentityResolvingKey", "Key", NULL);
+ str = g_key_file_get_string(key_file, "IdentityResolvingKey", "Key",
+ NULL);
if (!str || strlen(str) < 32)
goto failed;
str2ba(peer, &irk->bdaddr);
irk->bdaddr_type = bdaddr_type;
+ /* Fix up address type if it was stored with the wrong
+ * address type since Load Identity Keys are only meant
+ * to work with LE addresses as per MGMT documentation.
+ */
+ if (irk->bdaddr_type == BDADDR_BREDR)
+ irk->bdaddr_type = BDADDR_LE_PUBLIC;
+
if (!strncmp(str, "0x", 2))
str2buf(&str[2], irk->val, sizeof(irk->val));
else
goto free;
}
- if (key_info) {
- /* Fix up address type if it was stored with the wrong
- * address type since Load Link Keys are only meant to
- * work with BR/EDR addresses as per MGMT documentation.
- */
- if (key_info->bdaddr_type != BDADDR_BREDR)
- key_info->bdaddr_type = BDADDR_BREDR;
-
+ if (key_info)
keys = g_slist_append(keys, key_info);
- }
-
- if (ltk_info) {
- /* Fix up address type if it was stored with the wrong
- * address type since Load Long Term Keys are only meant
- * to work with LE addresses as per MGMT documentation.
- */
- if (ltk_info->bdaddr_type == BDADDR_BREDR)
- ltk_info->bdaddr_type = BDADDR_LE_PUBLIC;
+ if (ltk_info)
ltks = g_slist_append(ltks, ltk_info);
- }
if (peripheral_ltk_info)
ltks = g_slist_append(ltks, peripheral_ltk_info);