Skip to content

Commit 40dc9ec

Browse files
committed
utils: fix crash when using MAC addresses as client identifiers
1 parent 04d68e7 commit 40dc9ec

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/util.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -908,15 +908,16 @@ int netlink_get_neighbors(int family,
908908
continue;
909909
}
910910

911-
unsigned int rtalen = len;
912-
for (nlh = (struct nlmsghdr *)buf; NLMSG_OK(nlh, rtalen); nlh = NLMSG_NEXT(nlh, rtalen)) {
911+
int nlh_len = len;
912+
for (nlh = (struct nlmsghdr *)buf; NLMSG_OK(nlh, nlh_len); nlh = NLMSG_NEXT(nlh, nlh_len)) {
913913
ndm = NLMSG_DATA(nlh);
914914
struct rtattr *rta = RTM_RTA(ndm);
915915
const uint8_t *mac = NULL;
916916
const uint8_t *net_addr = NULL;
917917
int net_addr_len = 0;
918+
int rta_len = RTM_PAYLOAD(nlh);
918919

919-
for (; RTA_OK(rta, rtalen); rta = RTA_NEXT(rta, rtalen)) {
920+
for (; RTA_OK(rta, rta_len); rta = RTA_NEXT(rta, rta_len)) {
920921
if (rta->rta_type == NDA_DST) {
921922
if (ndm->ndm_family == AF_INET) {
922923
struct in_addr *addr = RTA_DATA(rta);

0 commit comments

Comments
 (0)