No subject

Unknown Unknown
Sun Feb 25 07:26:00 PST 2007


-- 
Hasso Tepper

--nextPart5107881.kJsXstJZeP
Content-Type: text/x-diff; name="df_cmsg_firsthdr.patch"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="df_cmsg_firsthdr.patch"

Index: socket.h
===================================================================
RCS file: /DragonflyBSD/src/sys/sys/socket.h,v
retrieving revision 1.18
diff -u -p -r1.18 socket.h
--- socket.h	18 Jan 2007 11:46:32 -0000	1.18
+++ socket.h	25 Feb 2007 15:10:13 -0000
@@ -407,7 +407,14 @@ struct cmsgcred {
 	    (struct cmsghdr *)NULL : \
 	    (struct cmsghdr *)((caddr_t)(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)
 
 /* RFC 2292 additions */
 	


--nextPart5107881.kJsXstJZeP--





More information about the Submit mailing list