Ondřej Jirman
2018-11-20 23:29:50 UTC
Hello,
This line:
grep -R RTA_OK
src/network/netlink.h:#define RTA_OK(nlh,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
only works by accident, because all uses of NLMSG_RTAOK reference rta variable:
src/network/getifaddrs.c: for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
src/network/getifaddrs.c: for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
src/network/getifaddrs.c: for (rta = NLMSG_RTA(h, sizeof(*ifa)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
src/network/netlink.h:#define NLMSG_RTAOK(rta,nlh) RTA_OK(rta,NLMSG_DATAEND(nlh))
src/network/if_nameindex.c: for (; NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
I suggest:
-#define RTA_OK(nlh,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
+#define RTA_OK(rta,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
thank you and regards,
o.
This line:
grep -R RTA_OK
src/network/netlink.h:#define RTA_OK(nlh,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
only works by accident, because all uses of NLMSG_RTAOK reference rta variable:
src/network/getifaddrs.c: for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
src/network/getifaddrs.c: for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
src/network/getifaddrs.c: for (rta = NLMSG_RTA(h, sizeof(*ifa)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
src/network/netlink.h:#define NLMSG_RTAOK(rta,nlh) RTA_OK(rta,NLMSG_DATAEND(nlh))
src/network/if_nameindex.c: for (; NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
I suggest:
-#define RTA_OK(nlh,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
+#define RTA_OK(rta,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
thank you and regards,
o.