D-Bus: Fix Introspect() in case of os_strdup() failure
add_interface() did not check for os_strdup() return value and could end up dereferencing a NULL pointer if memory allocation failed. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
68a866974b
commit
dacf605812
1 changed files with 4 additions and 2 deletions
|
@ -37,14 +37,16 @@ static struct interfaces * add_interface(struct dl_list *list,
|
||||||
iface = os_zalloc(sizeof(struct interfaces));
|
iface = os_zalloc(sizeof(struct interfaces));
|
||||||
if (!iface)
|
if (!iface)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
iface->dbus_interface = os_strdup(dbus_interface);
|
||||||
iface->xml = wpabuf_alloc(6000);
|
iface->xml = wpabuf_alloc(6000);
|
||||||
if (iface->xml == NULL) {
|
if (iface->dbus_interface == NULL || iface->xml == NULL) {
|
||||||
|
os_free(iface->dbus_interface);
|
||||||
|
wpabuf_free(iface->xml);
|
||||||
os_free(iface);
|
os_free(iface);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wpabuf_printf(iface->xml, "<interface name=\"%s\">", dbus_interface);
|
wpabuf_printf(iface->xml, "<interface name=\"%s\">", dbus_interface);
|
||||||
dl_list_add_tail(list, &iface->list);
|
dl_list_add_tail(list, &iface->list);
|
||||||
iface->dbus_interface = os_strdup(dbus_interface);
|
|
||||||
return iface;
|
return iface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue