Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/sys/socket.h,v retrieving revision 1.60.2.1 retrieving revision 1.60.2.2 diff -u -p -r1.60.2.1 -r1.60.2.2 --- src/sys/sys/socket.h 2001/08/03 04:14:05 1.60.2.1 +++ src/sys/sys/socket.h 2001/09/13 01:16:28 1.60.2.2 @@ -1,4 +1,4 @@ -/* $NetBSD: socket.h,v 1.60.2.1 2001/08/03 04:14:05 lukem Exp $ */ +/* $NetBSD: socket.h,v 1.60.2.2 2001/09/13 01:16:28 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -431,7 +431,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) #define CMSG_SPACE(l) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(l)) #define CMSG_LEN(l) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (l))