gentoo-ebuilds/sys-libs/musl/files/musl-getifaddrs-qemu-workaround.patch
Sam James f3c0c2bd8c
sys-libs/musl: fix QEMU workaround patch
This is still applied in 1.2.5-r6 but it is masked.

Bug: https://bugs.gentoo.org/914256
Closes: https://bugs.gentoo.org/966043
Signed-off-by: Sam James <sam@gentoo.org>
2025-11-14 01:47:30 +00:00

25 lines
1.4 KiB
Diff

https://www.openwall.com/lists/musl/2018/06/02/4
https://gitlab.com/qemu-project/qemu/-/issues/2485
https://bugs.gentoo.org/914256
--- a/src/network/netlink.h
+++ b/src/network/netlink.h
@@ -80,13 +80,17 @@ struct ifaddrmsg {
#define NLMSG_DATALEN(nlh) ((nlh)->nlmsg_len-sizeof(struct nlmsghdr))
#define NLMSG_DATAEND(nlh) ((char*)(nlh)+(nlh)->nlmsg_len)
#define NLMSG_NEXT(nlh) (struct nlmsghdr*)((char*)(nlh)+NETLINK_ALIGN((nlh)->nlmsg_len))
-#define NLMSG_OK(nlh,end) ((char*)(end)-(char*)(nlh) >= sizeof(struct nlmsghdr))
+#define NLMSG_OK(nlh,end) ((char*)(end)-(char*)(nlh) >= sizeof(struct nlmsghdr) && \
+ (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
+ (nlh)->nlmsg_len <= ((char*)(end)-(char*)(nlh)))
#define RTA_DATA(rta) ((void*)((char*)(rta)+sizeof(struct rtattr)))
#define RTA_DATALEN(rta) ((rta)->rta_len-sizeof(struct rtattr))
#define RTA_DATAEND(rta) ((char*)(rta)+(rta)->rta_len)
#define RTA_NEXT(rta) (struct rtattr*)((char*)(rta)+NETLINK_ALIGN((rta)->rta_len))
-#define RTA_OK(rta,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr))
+#define RTA_OK(rta,end) ((char*)(end)-(char*)(rta) >= sizeof(struct rtattr) && \
+ (rta)->rta_len >= sizeof(struct rtattr) && \
+ (rta)->rta_len <= ((char*)(end)-(char*)(rta)))
#define NLMSG_RTA(nlh,len) ((void*)((char*)(nlh)+sizeof(struct nlmsghdr)+NETLINK_ALIGN(len)))
#define NLMSG_RTAOK(rta,nlh) RTA_OK(rta,NLMSG_DATAEND(nlh))