Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys make CMSG_FIRSTHDR() validat emsg_controllen, as sug...
details: https://anonhg.NetBSD.org/src/rev/7525a142c5f0
branches: trunk
changeset: 514641:7525a142c5f0
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Sep 07 08:13:01 2001 +0000
description:
make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame
diffstat:
sys/sys/socket.h | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diffs (25 lines):
diff -r c6769e8a4bcd -r 7525a142c5f0 sys/sys/socket.h
--- a/sys/sys/socket.h Fri Sep 07 07:19:52 2001 +0000
+++ b/sys/sys/socket.h Fri Sep 07 08:13:01 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socket.h,v 1.61 2001/07/17 11:49:41 jdolecek Exp $ */
+/* $NetBSD: socket.h,v 1.62 2001/09/07 08:13:01 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -431,7 +431,14 @@
(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))
Home |
Main Index |
Thread Index |
Old Index