diff options
| author | Christoph Hellwig <hch@lst.de> | 2004-06-28 01:32:38 -0700 |
|---|---|---|
| committer | Christoph Hellwig <hch@lst.de> | 2004-06-28 01:32:38 -0700 |
| commit | f3ab2e3236b50c2102508fd3166596bcffc7394c (patch) | |
| tree | 3548e19e8d5f7ef703a8ca131e6d2d1410b8b9b8 /include | |
| parent | 371135bd6e10d0d00a4437b5c7f75e231ef649ce (diff) | |
[NETLINK]: Fix NLMSG_OK/RTA_OK length checking.
Verify at least a full header is there before derefencing
length struct member.
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/netlink.h | 3 | ||||
| -rw-r--r-- | include/linux/rtnetlink.h | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 0602eaffbad2..16af86e4743a 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -73,7 +73,8 @@ struct nlmsghdr #define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) -#define NLMSG_OK(nlh,len) ((len) > 0 && (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ +#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ (nlh)->nlmsg_len <= (len)) #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len))) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 366eae3b4fc3..4f949964bb9b 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -73,7 +73,8 @@ struct rtattr #define RTA_ALIGNTO 4 #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) ) -#define RTA_OK(rta,len) ((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \ +#define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \ + (rta)->rta_len >= sizeof(struct rtattr) && \ (rta)->rta_len <= (len)) #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \ (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len))) |
