- merge revision 1.6
authorMark Huang <mlhuang@cs.princeton.edu>
Thu, 27 Jan 2005 20:43:12 +0000 (20:43 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Thu, 27 Jan 2005 20:43:12 +0000 (20:43 +0000)
date: 2005/01/19 22:42:27;  author: mef;  state: Exp;  lines: +4 -0
Fixes CAN-2004 security reports 1016, 1017, and 1068

include/linux/socket.h

index 602d03b..f30253c 100644 (file)
@@ -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