Skip to content

Commit

Permalink
utils: fix crash when using MAC addresses as client identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
pymumu committed Mar 9, 2024
1 parent 04d68e7 commit 40dc9ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,15 +908,16 @@ int netlink_get_neighbors(int family,
continue;
}

unsigned int rtalen = len;
for (nlh = (struct nlmsghdr *)buf; NLMSG_OK(nlh, rtalen); nlh = NLMSG_NEXT(nlh, rtalen)) {
int nlh_len = len;
for (nlh = (struct nlmsghdr *)buf; NLMSG_OK(nlh, nlh_len); nlh = NLMSG_NEXT(nlh, nlh_len)) {
ndm = NLMSG_DATA(nlh);
struct rtattr *rta = RTM_RTA(ndm);
const uint8_t *mac = NULL;
const uint8_t *net_addr = NULL;
int net_addr_len = 0;
int rta_len = RTM_PAYLOAD(nlh);

for (; RTA_OK(rta, rtalen); rta = RTA_NEXT(rta, rtalen)) {
for (; RTA_OK(rta, rta_len); rta = RTA_NEXT(rta, rta_len)) {
if (rta->rta_type == NDA_DST) {
if (ndm->ndm_family == AF_INET) {
struct in_addr *addr = RTA_DATA(rta);
Expand Down

0 comments on commit 40dc9ec

Please sign in to comment.