D-Bus: Fix P2P DeleteService dict iteration
The previous implementation assumed the first entry coming out from the dict is always service_type. That may not be the case, so properly iterate over all dict entries in one loop instead of assuming what the first entry is. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
366ada0412
commit
a68e9b6980
1 changed files with 17 additions and 35 deletions
|
@ -2693,7 +2693,7 @@ DBusMessage * wpas_dbus_handler_p2p_delete_service(
|
||||||
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
||||||
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -2705,27 +2705,27 @@ DBusMessage * wpas_dbus_handler_p2p_delete_service(
|
||||||
bonjour = 1;
|
bonjour = 1;
|
||||||
else
|
else
|
||||||
goto error_clear;
|
goto error_clear;
|
||||||
|
} else if (os_strcmp(entry.key, "version") == 0 &&
|
||||||
|
entry.type == DBUS_TYPE_INT32) {
|
||||||
|
version = entry.uint32_value;
|
||||||
|
} else if (os_strcmp(entry.key, "service") == 0 &&
|
||||||
|
entry.type == DBUS_TYPE_STRING) {
|
||||||
|
os_free(service);
|
||||||
|
service = os_strdup(entry.str_value);
|
||||||
|
} else if (os_strcmp(entry.key, "query") == 0) {
|
||||||
|
if (entry.type != DBUS_TYPE_ARRAY ||
|
||||||
|
entry.array_type != DBUS_TYPE_BYTE)
|
||||||
|
goto error_clear;
|
||||||
|
wpabuf_free(query);
|
||||||
|
query = wpabuf_alloc_copy(entry.bytearray_value,
|
||||||
|
entry.array_len);
|
||||||
|
} else {
|
||||||
|
goto error_clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
wpa_dbus_dict_entry_clear(&entry);
|
wpa_dbus_dict_entry_clear(&entry);
|
||||||
}
|
}
|
||||||
if (upnp == 1) {
|
if (upnp == 1) {
|
||||||
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
||||||
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
||||||
goto error;
|
|
||||||
if (os_strcmp(entry.key, "version") == 0 &&
|
|
||||||
entry.type == DBUS_TYPE_INT32)
|
|
||||||
version = entry.uint32_value;
|
|
||||||
else if (os_strcmp(entry.key, "service") == 0 &&
|
|
||||||
entry.type == DBUS_TYPE_STRING) {
|
|
||||||
os_free(service);
|
|
||||||
service = os_strdup(entry.str_value);
|
|
||||||
} else
|
|
||||||
goto error_clear;
|
|
||||||
|
|
||||||
wpa_dbus_dict_entry_clear(&entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version <= 0 || service == NULL)
|
if (version <= 0 || service == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -2733,24 +2733,6 @@ DBusMessage * wpas_dbus_handler_p2p_delete_service(
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto error;
|
goto error;
|
||||||
} else if (bonjour == 1) {
|
} else if (bonjour == 1) {
|
||||||
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
||||||
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (os_strcmp(entry.key, "query") == 0) {
|
|
||||||
if (entry.type != DBUS_TYPE_ARRAY ||
|
|
||||||
entry.array_type != DBUS_TYPE_BYTE)
|
|
||||||
goto error_clear;
|
|
||||||
wpabuf_free(query);
|
|
||||||
query = wpabuf_alloc_copy(
|
|
||||||
entry.bytearray_value,
|
|
||||||
entry.array_len);
|
|
||||||
} else
|
|
||||||
goto error_clear;
|
|
||||||
|
|
||||||
wpa_dbus_dict_entry_clear(&entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query == NULL)
|
if (query == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue