mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-01 16:22:44 +01:00
netdev: Check GTK / IGTK buffer length before memcpying from it
Move key length checks in netdev_set_gtk/netdev_set_igtk to before we memcpy from the buffer.
This commit is contained in:
parent
c033fcbf5e
commit
3a4887fef4
28
src/netdev.c
28
src/netdev.c
@ -795,6 +795,13 @@ static void netdev_set_gtk(uint32_t ifindex, uint8_t key_index,
|
|||||||
|
|
||||||
l_debug("%d", netdev->index);
|
l_debug("%d", netdev->index);
|
||||||
|
|
||||||
|
if (crypto_cipher_key_len(cipher) != gtk_len) {
|
||||||
|
l_error("Unexpected key length: %d", gtk_len);
|
||||||
|
netdev_setting_keys_failed(netdev,
|
||||||
|
MPDU_REASON_CODE_INVALID_GROUP_CIPHER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (cipher) {
|
switch (cipher) {
|
||||||
case CRYPTO_CIPHER_CCMP:
|
case CRYPTO_CIPHER_CCMP:
|
||||||
memcpy(gtk_buf, gtk, 16);
|
memcpy(gtk_buf, gtk, 16);
|
||||||
@ -824,13 +831,6 @@ static void netdev_set_gtk(uint32_t ifindex, uint8_t key_index,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crypto_cipher_key_len(cipher) != gtk_len) {
|
|
||||||
l_error("Unexpected key length: %d", gtk_len);
|
|
||||||
netdev_setting_keys_failed(netdev,
|
|
||||||
MPDU_REASON_CODE_INVALID_GROUP_CIPHER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg = netdev_build_cmd_new_key_group(netdev, cipher, key_index,
|
msg = netdev_build_cmd_new_key_group(netdev, cipher, key_index,
|
||||||
gtk_buf, gtk_len,
|
gtk_buf, gtk_len,
|
||||||
rsc, rsc_len);
|
rsc, rsc_len);
|
||||||
@ -858,6 +858,13 @@ static void netdev_set_igtk(uint32_t ifindex, uint8_t key_index,
|
|||||||
|
|
||||||
l_debug("%d", netdev->index);
|
l_debug("%d", netdev->index);
|
||||||
|
|
||||||
|
if (crypto_cipher_key_len(cipher) != igtk_len) {
|
||||||
|
l_error("Unexpected key length: %d", igtk_len);
|
||||||
|
netdev_setting_keys_failed(netdev,
|
||||||
|
MPDU_REASON_CODE_INVALID_GROUP_CIPHER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (cipher) {
|
switch (cipher) {
|
||||||
case CRYPTO_CIPHER_BIP:
|
case CRYPTO_CIPHER_BIP:
|
||||||
memcpy(igtk_buf, igtk, 16);
|
memcpy(igtk_buf, igtk, 16);
|
||||||
@ -869,13 +876,6 @@ static void netdev_set_igtk(uint32_t ifindex, uint8_t key_index,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crypto_cipher_key_len(cipher) != igtk_len) {
|
|
||||||
l_error("Unexpected key length: %d", igtk_len);
|
|
||||||
netdev_setting_keys_failed(netdev,
|
|
||||||
MPDU_REASON_CODE_INVALID_GROUP_CIPHER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg = netdev_build_cmd_new_key_group(netdev, cipher, key_index,
|
msg = netdev_build_cmd_new_key_group(netdev, cipher, key_index,
|
||||||
igtk_buf, igtk_len,
|
igtk_buf, igtk_len,
|
||||||
ipn, ipn_len);
|
ipn, ipn_len);
|
||||||
|
Loading…
Reference in New Issue
Block a user