diff options
-rw-r--r-- | sys/sys/socket.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/sys/socket.h b/sys/sys/socket.h index b09c37f47e7..91044272a29 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.h,v 1.38 2001/06/26 19:56:51 dugsong Exp $ */ +/* $OpenBSD: socket.h,v 1.39 2001/09/07 16:45:25 itojun Exp $ */ /* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */ /* @@ -360,7 +360,14 @@ struct cmsghdr { (struct cmsghdr *)NULL : \ (struct cmsghdr *)((caddr_t)(cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len))) -#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) +/* + * RFC 2292 requires to check msg_controllen, in case that the kernel returns + * an empty list for some reasons. + */ +#define CMSG_FIRSTHDR(mhdr) \ + ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(mhdr)->msg_control : \ + (struct cmsghdr *)NULL) /* Round len up to next alignment boundary */ #define __CMSG_ALIGN(len) ALIGN(len) |