]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Clean up array-array-type property getter
authorJouni Malinen <j@w1.fi>
Sun, 29 Jun 2014 15:20:13 +0000 (18:20 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 29 Jun 2014 15:20:13 +0000 (18:20 +0300)
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>
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/dbus/dbus_new_handlers_p2p.c

index f5efd8be267a349e7299bcac2bd315594964206c..6dc5f76d4caba9b182af0e2a87ebdf706f09c2d9 100644 (file)
@@ -512,7 +512,7 @@ dbus_bool_t wpas_dbus_simple_array_array_property_getter(DBusMessageIter *iter,
                return FALSE;
        }
 
-       for (i = 0; i < array_len; i++) {
+       for (i = 0; i < array_len && array[i]; i++) {
                wpa_dbus_dict_bin_array_add_element(&array_iter,
                                                    wpabuf_head(array[i]),
                                                    wpabuf_len(array[i]));
index a3b63bccec05fbecf2144cf6b60e5e2cfab7f2f1..516551a9887fcb8af04c2a1716c3a4e273e530a6 100644 (file)
@@ -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) {