]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Use cleaner way of generating pointer to a field (CID 68095)
authorJouni Malinen <j@w1.fi>
Thu, 12 Jun 2014 17:13:50 +0000 (20:13 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 12 Jun 2014 21:27:15 +0000 (00:27 +0300)
The Action code field is in a fixed location, so the IEEE80211_HDRLEN
can be used here to clean up bounds checking to avoid false reports from
static analyzer.

Signed-off-by: Jouni Malinen <j@w1.fi>
wpa_supplicant/ap.c

index b02c424fdf0e2fe869233d29914a859f290f4742..92fe7fe86db44e7696487f69d8a4798719104a87 100644 (file)
@@ -373,18 +373,16 @@ static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
 #ifdef CONFIG_P2P
        struct wpa_supplicant *wpa_s = ctx;
        const struct ieee80211_mgmt *mgmt;
-       size_t hdr_len;
 
        mgmt = (const struct ieee80211_mgmt *) buf;
-       hdr_len = (const u8 *) &mgmt->u.action.u.vs_public_action.action - buf;
-       if (hdr_len > len)
+       if (len < IEEE80211_HDRLEN + 1)
                return;
        if (mgmt->u.action.category != WLAN_ACTION_PUBLIC)
                return;
        wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
                           mgmt->u.action.category,
-                          &mgmt->u.action.u.vs_public_action.action,
-                          len - hdr_len, freq);
+                          buf + IEEE80211_HDRLEN + 1,
+                          len - IEEE80211_HDRLEN - 1, freq);
 #endif /* CONFIG_P2P */
 }