diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 1ad48dd79..65f5ce5f2 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -753,7 +753,7 @@ struct wpa_driver_ops { * @seq: sequence number/packet number, seq_len octets, the next * packet number to be used for in replay protection; configured * for Rx keys (in most cases, this is only used with broadcast - * keys and set to zero for unicast keys) + * keys and set to zero for unicast keys); %NULL if not set * @seq_len: length of the seq, depends on the algorithm: * TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, diff --git a/src/drivers/driver_atmel.c b/src/drivers/driver_atmel.c index cbec6c38d..8d748d386 100644 --- a/src/drivers/driver_atmel.c +++ b/src/drivers/driver_atmel.c @@ -248,7 +248,8 @@ static int wpa_driver_atmel_set_key(const char *ifname, void *priv, param->alg = alg_type; param->key_idx = key_idx; param->set_tx = set_tx; - os_memcpy(param->seq, seq, seq_len); + if (seq) + os_memcpy(param->seq, seq, seq_len); param->seq_len = seq_len; param->key_len = key_len; os_memcpy((u8 *)param->key, key, key_len); diff --git a/src/drivers/driver_bsd.c b/src/drivers/driver_bsd.c index 6067dc391..c9520ec1a 100644 --- a/src/drivers/driver_bsd.c +++ b/src/drivers/driver_bsd.c @@ -347,7 +347,8 @@ bsd_set_key(const char *ifname, void *priv, enum wpa_alg alg, if (wk.ik_keyix != IEEE80211_KEYIX_NONE && set_tx) wk.ik_flags |= IEEE80211_KEY_DEFAULT; wk.ik_keylen = key_len; - os_memcpy(&wk.ik_keyrsc, seq, seq_len); + if (seq) + os_memcpy(&wk.ik_keyrsc, seq, seq_len); os_memcpy(wk.ik_keydata, key, key_len); return set80211var(priv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)); diff --git a/src/drivers/driver_hostap.c b/src/drivers/driver_hostap.c index e47983cb7..624293b76 100644 --- a/src/drivers/driver_hostap.c +++ b/src/drivers/driver_hostap.c @@ -1307,7 +1307,8 @@ static int wpa_driver_hostap_set_key(const char *ifname, void *priv, HOSTAP_CRYPT_ALG_NAME_LEN); param->u.crypt.flags = set_tx ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0; param->u.crypt.idx = key_idx; - os_memcpy(param->u.crypt.seq, seq, seq_len); + if (seq) + os_memcpy(param->u.crypt.seq, seq, seq_len); param->u.crypt.key_len = key_len; os_memcpy((u8 *) (param + 1), key, key_len); diff --git a/src/drivers/driver_ipw.c b/src/drivers/driver_ipw.c index 77984f9e5..d6c8f2939 100644 --- a/src/drivers/driver_ipw.c +++ b/src/drivers/driver_ipw.c @@ -264,7 +264,8 @@ static int wpa_driver_ipw_set_key(const char *ifname, void *priv, IPW_CRYPT_ALG_NAME_LEN); param->u.crypt.set_tx = set_tx ? 1 : 0; param->u.crypt.idx = key_idx; - os_memcpy(param->u.crypt.seq, seq, seq_len); + if (seq) + os_memcpy(param->u.crypt.seq, seq, seq_len); param->u.crypt.key_len = key_len; os_memcpy((u8 *) (param + 1), key, key_len); diff --git a/src/drivers/driver_madwifi.c b/src/drivers/driver_madwifi.c index ebbdfeb3b..570fc4c96 100644 --- a/src/drivers/driver_madwifi.c +++ b/src/drivers/driver_madwifi.c @@ -1511,7 +1511,7 @@ wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg, wk.ik_keyix = key_idx; wk.ik_keylen = key_len; #ifdef WORDS_BIGENDIAN - { + if (seq) { size_t i; u8 tmp[WPA_KEY_RSC_LEN]; os_memset(tmp, 0, sizeof(tmp)); @@ -1520,7 +1520,8 @@ wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg, os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN); } #else /* WORDS_BIGENDIAN */ - os_memcpy(&wk.ik_keyrsc, seq, seq_len); + if (seq) + os_memcpy(&wk.ik_keyrsc, seq, seq_len); #endif /* WORDS_BIGENDIAN */ os_memcpy(wk.ik_keydata, key, key_len); diff --git a/src/drivers/driver_ndiswrapper.c b/src/drivers/driver_ndiswrapper.c index cd2f61e46..3abdb6442 100644 --- a/src/drivers/driver_ndiswrapper.c +++ b/src/drivers/driver_ndiswrapper.c @@ -128,7 +128,7 @@ static int wpa_ndiswrapper_set_key(const char *ifname, void *priv, wpa_key.addr = addr; wpa_key.key_index = key_idx; wpa_key.set_tx = set_tx; - wpa_key.seq = seq; + wpa_key.seq = seq ? seq : (u8 *) ""; wpa_key.seq_len = seq_len; wpa_key.key = key; wpa_key.key_len = key_len; diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 6658e5355..18bb39580 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -134,7 +134,7 @@ int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) set = 1; wpa_drv_set_key(wpa_s, WPA_ALG_WEP, (u8 *) "\xff\xff\xff\xff\xff\xff", - i, i == ssid->wep_tx_keyidx, (u8 *) "", 0, + i, i == ssid->wep_tx_keyidx, NULL, 0, ssid->wep_key[i], ssid->wep_key_len[i]); } diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c index 4af0cd032..607f44b0f 100644 --- a/wpa_supplicant/wpas_glue.c +++ b/wpa_supplicant/wpas_glue.c @@ -212,7 +212,7 @@ static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx, return wpa_drv_set_key(wpa_s, WPA_ALG_WEP, unicast ? wpa_s->bssid : (u8 *) "\xff\xff\xff\xff\xff\xff", - keyidx, unicast, (u8 *) "", 0, key, keylen); + keyidx, unicast, NULL, 0, key, keylen); }