3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 18:59:22 +01:00

netdev: Use mpdu_validate on received registered frames

This way the individual frame handlers have less validation to do.
This commit is contained in:
Andrew Zaborowski 2017-09-22 05:06:33 +02:00 committed by Denis Kenzior
parent 8db7725e0b
commit 45c4e0589b

View File

@ -2819,7 +2819,7 @@ static void netdev_mgmt_frame_event(struct l_genl_msg *msg,
struct netdev *netdev) struct netdev *netdev)
{ {
struct l_genl_attr attr; struct l_genl_attr attr;
uint16_t type, len, frame_len = 0; uint16_t type, len, frame_len;
const void *data; const void *data;
const struct mmpdu_header *mpdu = NULL; const struct mmpdu_header *mpdu = NULL;
const uint8_t *body; const uint8_t *body;
@ -2834,18 +2834,19 @@ static void netdev_mgmt_frame_event(struct l_genl_msg *msg,
if (mpdu) if (mpdu)
return; return;
mpdu = data; mpdu = mpdu_validate(data, len);
if (!mpdu)
l_error("Frame didn't validate as MMPDU");
frame_len = len; frame_len = len;
break; break;
} }
} }
if (!mpdu || frame_len < 24) if (!mpdu)
return; return;
body = mmpdu_body(mpdu); body = mmpdu_body(mpdu);
if (body > (uint8_t *) mpdu + frame_len)
return;
if (memcmp(mpdu->address_1, netdev->addr, 6) && if (memcmp(mpdu->address_1, netdev->addr, 6) &&
!util_is_broadcast_address(mpdu->address_1)) !util_is_broadcast_address(mpdu->address_1))