aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2014-06-29 15:20:13 (GMT)
committerJouni Malinen <j@w1.fi>2014-06-29 15:20:13 (GMT)
commit010fc5f507020f69f64b958450eb5136e9d6db77 (patch)
treecafb98d0deefd13138e565df170687cf727322c9 /wpa_supplicant/dbus/dbus_new_handlers_p2p.c
parentea18024d78bde140fb8f74d216d757816bfd6e9b (diff)
downloadhostap-010fc5f507020f69f64b958450eb5136e9d6db77.zip
hostap-010fc5f507020f69f64b958450eb5136e9d6db77.tar.gz
hostap-010fc5f507020f69f64b958450eb5136e9d6db77.tar.bz2
dbus: Clean up array-array-type property getter
The previously used design was a bit too complex for static analyzers (e.g., CID 68131, CID 68133) to understand which resulted in false warnings about uninitialized memory. Avoid this by explicitly initializing the pointer array to NULL and also skipping any invalid NULL entry in the helper function. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/dbus/dbus_new_handlers_p2p.c')
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_p2p.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index a3b63bc..516551a 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -1455,7 +1455,7 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_vendor_extension(DBusMessageIter *iter,
void *user_data)
{
struct wpabuf *vendor_extension[P2P_MAX_WPS_VENDOR_EXT];
- int i, num;
+ unsigned int i, num = 0;
struct peer_handler_args *peer_args = user_data;
const struct p2p_peer_info *info;
@@ -1468,7 +1468,8 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_vendor_extension(DBusMessageIter *iter,
}
/* Add WPS vendor extensions attribute */
- for (i = 0, num = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
+ os_memset(vendor_extension, 0, sizeof(vendor_extension));
+ for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
if (info->wps_vendor_ext[i] == NULL)
continue;
vendor_extension[num] = info->wps_vendor_ext[i];
@@ -2115,8 +2116,9 @@ dbus_bool_t wpas_dbus_getter_p2p_group_vendor_ext(DBusMessageIter *iter,
struct wpa_supplicant *wpa_s = user_data;
struct hostapd_data *hapd;
struct wpabuf *vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
- int num_vendor_ext = 0;
- int i;
+ unsigned int i, num_vendor_ext = 0;
+
+ os_memset(vendor_ext, 0, sizeof(vendor_ext));
/* Verify correct role for this property */
if (wpas_get_p2p_role(wpa_s) == WPAS_P2P_ROLE_GO) {