DragonFly submit List (threaded) for 2007-02
DragonFly BSD
DragonFly submit List (threaded) for 2007-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[no subject]



-- 
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--



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]