summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2004-12-07 20:49:21 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-12-07 20:49:21 -0800
commit620512af09f33236b4ea04372816b761d48586d9 (patch)
tree65ac3c63230cdd8063176b9a46183c021fb15d41 /include/linux
parent4c20da44c2f1228ea6cc805ed9236c03d5fa2a9a (diff)
[NET]: Fix CMSG validation checks wrt. signedness.
Noticed by Georgi Guninski. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/socket.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/socket.h b/include/linux/socket.h
index b3aef7bf1380..4c7d11301abf 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -90,6 +90,10 @@ struct cmsghdr {
(struct cmsghdr *)(ctl) : \
(struct cmsghdr *)NULL)
#define CMSG_FIRSTHDR(msg) __CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && \
+ (cmsg)->cmsg_len <= (unsigned long) \
+ ((mhdr)->msg_controllen - \
+ ((char *)(cmsg) - (char *)(mhdr)->msg_control)))
/*
* This mess will go away with glibc