From 45c4e0589bba5de7ce1af27b4ffabb2af2949ba5 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Fri, 22 Sep 2017 05:06:33 +0200 Subject: [PATCH] netdev: Use mpdu_validate on received registered frames This way the individual frame handlers have less validation to do. --- src/netdev.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index baed4636..9e6496a3 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2819,7 +2819,7 @@ static void netdev_mgmt_frame_event(struct l_genl_msg *msg, struct netdev *netdev) { struct l_genl_attr attr; - uint16_t type, len, frame_len = 0; + uint16_t type, len, frame_len; const void *data; const struct mmpdu_header *mpdu = NULL; const uint8_t *body; @@ -2834,18 +2834,19 @@ static void netdev_mgmt_frame_event(struct l_genl_msg *msg, if (mpdu) return; - mpdu = data; + mpdu = mpdu_validate(data, len); + if (!mpdu) + l_error("Frame didn't validate as MMPDU"); + frame_len = len; break; } } - if (!mpdu || frame_len < 24) + if (!mpdu) return; body = mmpdu_body(mpdu); - if (body > (uint8_t *) mpdu + frame_len) - return; if (memcmp(mpdu->address_1, netdev->addr, 6) && !util_is_broadcast_address(mpdu->address_1))