Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 72458
Collapse All | Expand All

(-)1.12/include/linux/socket.h (+4 lines)
Lines 90-95 Link Here
90
				  (struct cmsghdr *)(ctl) : \
90
				  (struct cmsghdr *)(ctl) : \
91
				  (struct cmsghdr *)NULL)
91
				  (struct cmsghdr *)NULL)
92
#define CMSG_FIRSTHDR(msg)	__CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
92
#define CMSG_FIRSTHDR(msg)	__CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
93
#define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && \
94
			     (cmsg)->cmsg_len <= (unsigned long) \
95
			     ((mhdr)->msg_controllen - \
96
			      ((char *)(cmsg) - (char *)(mhdr)->msg_control)))
93
97
94
/*
98
/*
95
 *	This mess will go away with glibc
99
 *	This mess will go away with glibc
(-)1.10/net/core/scm.c (-3 / +1 lines)
Lines 127-135 Link Here
127
		   for too short ancillary data object at all! Oops.
127
		   for too short ancillary data object at all! Oops.
128
		   OK, let's add it...
128
		   OK, let's add it...
129
		 */
129
		 */
130
		if (cmsg->cmsg_len < sizeof(struct cmsghdr) ||
130
		if (!CMSG_OK(msg, cmsg))
131
		    (unsigned long)(((char*)cmsg - (char*)msg->msg_control)
132
				    + cmsg->cmsg_len) > msg->msg_controllen)
133
			goto error;
131
			goto error;
134
132
135
		if (cmsg->cmsg_level != SOL_SOCKET)
133
		if (cmsg->cmsg_level != SOL_SOCKET)
(-)1.26/net/ipv4/ip_sockglue.c (-4 / +1 lines)
Lines 146-156 Link Here
146
	struct cmsghdr *cmsg;
146
	struct cmsghdr *cmsg;
147
147
148
	for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
148
	for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
149
		if (cmsg->cmsg_len < sizeof(struct cmsghdr) ||
149
		if (!CMSG_OK(msg, cmsg))
150
		    (unsigned long)(((char*)cmsg - (char*)msg->msg_control)
151
				    + cmsg->cmsg_len) > msg->msg_controllen) {
152
			return -EINVAL;
150
			return -EINVAL;
153
		}
154
		if (cmsg->cmsg_level != SOL_IP)
151
		if (cmsg->cmsg_level != SOL_IP)
155
			continue;
152
			continue;
156
		switch (cmsg->cmsg_type) {
153
		switch (cmsg->cmsg_type) {
(-)1.20/net/ipv6/datagram.c (-3 / +1 lines)
Lines 427-435 Link Here
427
		int addr_type;
427
		int addr_type;
428
		struct net_device *dev = NULL;
428
		struct net_device *dev = NULL;
429
429
430
		if (cmsg->cmsg_len < sizeof(struct cmsghdr) ||
430
		if (!CMSG_OK(msg, cmsg)) {
431
		    (unsigned long)(((char*)cmsg - (char*)msg->msg_control)
432
				    + cmsg->cmsg_len) > msg->msg_controllen) {
433
			err = -EINVAL;
431
			err = -EINVAL;
434
			goto exit_f;
432
			goto exit_f;
435
		}
433
		}
(-)1.129/net/sctp/socket.c (-5 / +1 lines)
Lines 4098-4109 Link Here
4098
	for (cmsg = CMSG_FIRSTHDR(msg);
4098
	for (cmsg = CMSG_FIRSTHDR(msg);
4099
	     cmsg != NULL;
4099
	     cmsg != NULL;
4100
	     cmsg = CMSG_NXTHDR((struct msghdr*)msg, cmsg)) {
4100
	     cmsg = CMSG_NXTHDR((struct msghdr*)msg, cmsg)) {
4101
		/* Check for minimum length.  The SCM code has this check.  */
4101
		if (!CMSG_OK(msg, cmsg))
4102
		if (cmsg->cmsg_len < sizeof(struct cmsghdr) ||
4103
		    (unsigned long)(((char*)cmsg - (char*)msg->msg_control)
4104
				    + cmsg->cmsg_len) > msg->msg_controllen) {
4105
			return -EINVAL;
4102
			return -EINVAL;
4106
		}
4107
4103
4108
		/* Should we parse this header or ignore?  */
4104
		/* Should we parse this header or ignore?  */
4109
		if (cmsg->cmsg_level != IPPROTO_SCTP)
4105
		if (cmsg->cmsg_level != IPPROTO_SCTP)

Return to bug 72458