From 601079f99287eb26d40ccc3adb79886a8165a6ea Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Tue, 30 Aug 2005 15:59:49 +0000 Subject: [PATCH] o correct alignment of 802.11 addresses passed to ether_ntoa to fix segfaults on amd64 o while here correct printf formats for size_t args Identified by: Pascal Hofstee MFC after: 3 days --- usr.sbin/wpa/wpa_supplicant/driver_freebsd.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c b/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c index f14f03a57e0d..e69dcd5544a6 100644 --- a/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c +++ b/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -231,8 +232,11 @@ wpa_driver_bsd_del_key(struct wpa_driver_bsd_data *drv, int key_idx, memset(&wk, 0, sizeof(wk)); if (addr != NULL && bcmp(addr, "\xff\xff\xff\xff\xff\xff", IEEE80211_ADDR_LEN) != 0) { + struct ether_addr ea; + + memcpy(&ea, addr, IEEE80211_ADDR_LEN); wpa_printf(MSG_DEBUG, "%s: addr=%s keyidx=%d", - __func__, ether_ntoa(addr), key_idx); + __func__, ether_ntoa(&ea), key_idx); memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN); wk.idk_keyix = (uint8_t) IEEE80211_KEYIX_NONE; } else { @@ -250,6 +254,7 @@ wpa_driver_bsd_set_key(void *priv, wpa_alg alg, { struct wpa_driver_bsd_data *drv = priv; struct ieee80211req_key wk; + struct ether_addr ea; char *alg_name; u_int8_t cipher; @@ -275,18 +280,19 @@ wpa_driver_bsd_set_key(void *priv, wpa_alg alg, return -1; } + memcpy(&ea, addr, IEEE80211_ADDR_LEN); wpa_printf(MSG_DEBUG, - "%s: alg=%s addr=%s key_idx=%d set_tx=%d seq_len=%d key_len=%d", - __func__, alg_name, ether_ntoa(addr), key_idx, set_tx, + "%s: alg=%s addr=%s key_idx=%d set_tx=%d seq_len=%zu key_len=%zu", + __func__, alg_name, ether_ntoa(&ea), key_idx, set_tx, seq_len, key_len); if (seq_len > sizeof(u_int64_t)) { - wpa_printf(MSG_DEBUG, "%s: seq_len %d too big", + wpa_printf(MSG_DEBUG, "%s: seq_len %zu too big", __func__, seq_len); return -2; } if (key_len > sizeof(wk.ik_keydata)) { - wpa_printf(MSG_DEBUG, "%s: key length %d too big", + wpa_printf(MSG_DEBUG, "%s: key length %zu too big", __func__, key_len); return -3; }