summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/socketvar.h
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/sys/socketvar.h')
-rw-r--r--usr/src/uts/common/sys/socketvar.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/usr/src/uts/common/sys/socketvar.h b/usr/src/uts/common/sys/socketvar.h
index d00220f2a9..39112e6c97 100644
--- a/usr/src/uts/common/sys/socketvar.h
+++ b/usr/src/uts/common/sys/socketvar.h
@@ -544,11 +544,21 @@ struct sonodeops {
(((len) + _CMSG_HDR_ALIGNMENT - 1) & ~(_CMSG_HDR_ALIGNMENT - 1))
/*
- * Used in parsing msg_control
+ * Macros that operate on struct cmsghdr.
+ * Used in parsing msg_control.
+ * The CMSG_VALID macro does not assume that the last option buffer is padded.
*/
#define CMSG_NEXT(cmsg) \
(struct cmsghdr *)((uintptr_t)(cmsg) + \
ROUNDUP_cmsglen((cmsg)->cmsg_len))
+#define CMSG_CONTENT(cmsg) (&((cmsg)[1]))
+#define CMSG_CONTENTLEN(cmsg) ((cmsg)->cmsg_len - sizeof (struct cmsghdr))
+#define CMSG_VALID(cmsg, start, end) \
+ (ISALIGNED_cmsghdr(cmsg) && \
+ ((uintptr_t)(cmsg) >= (uintptr_t)(start)) && \
+ ((uintptr_t)(cmsg) < (uintptr_t)(end)) && \
+ ((ssize_t)(cmsg)->cmsg_len >= sizeof (struct cmsghdr)) && \
+ ((uintptr_t)(cmsg) + (cmsg)->cmsg_len <= (uintptr_t)(end)))
/*
* Maximum size of any argument that is copied in (addresses, options,