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.61 retrieving revision 1.61.2.1 diff -u -p -r1.61 -r1.61.2.1 --- src/sys/sys/socket.h 2001/07/17 11:49:41 1.61 +++ src/sys/sys/socket.h 2001/10/01 12:48:14 1.61.2.1 @@ -1,4 +1,4 @@ -/* $NetBSD: socket.h,v 1.61 2001/07/17 11:49:41 jdolecek Exp $ */ +/* $NetBSD: socket.h,v 1.61.2.1 2001/10/01 12:48:14 fvdl 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))