]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Fix arithmetic on void pointer
authorJesus Fernandez Manzano <jesus.manzano@galgus.net>
Wed, 9 Oct 2019 07:59:33 +0000 (09:59 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 25 Oct 2019 16:29:53 +0000 (19:29 +0300)
When using void pointers in calculations, the behavior is undefined.
Arithmetic operations on 'void *' is a GNU C extension,
which defines the 'sizeof(void)' to be 1.

This change improves portability of the code.

Signed-off-by: Jesus Fernandez Manzano <jesus.manzano@galgus.net>
wpa_supplicant/wpa_priv.c

index b3ad45eca516c3e4217dc2f875ff85ffa3de37a9..f19735277d5b17dfef45fcf21a521f7b8affab9c 100644 (file)
@@ -598,7 +598,7 @@ static void wpa_priv_cmd_l2_send(struct wpa_priv_interface *iface,
        }
 
        dst_addr = buf;
-       os_memcpy(&proto, buf + ETH_ALEN, 2);
+       os_memcpy(&proto, (char *) buf + ETH_ALEN, 2);
 
        if (!wpa_priv_allowed_l2_proto(proto)) {
                wpa_printf(MSG_DEBUG, "Refused l2_packet send for ethertype "
@@ -607,7 +607,8 @@ static void wpa_priv_cmd_l2_send(struct wpa_priv_interface *iface,
        }
 
        res = l2_packet_send(iface->l2[idx], dst_addr, proto,
-                            buf + ETH_ALEN + 2, len - ETH_ALEN - 2);
+                            (unsigned char *) buf + ETH_ALEN + 2,
+                            len - ETH_ALEN - 2);
        wpa_printf(MSG_DEBUG, "L2 send[idx=%d]: res=%d", idx, res);
 }