patch-2.1.22 linux/net/ipv4/ip_options.c

Next file: linux/net/ipv4/ip_sockglue.c
Previous file: linux/net/ipv4/ip_input.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.21/linux/net/ipv4/ip_options.c linux/net/ipv4/ip_options.c
@@ -484,15 +484,21 @@
 	}
 }
 
-int ip_options_getfromuser(struct ip_options **optp, unsigned char *data, int optlen)
+int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen, int user)
 {
 	struct ip_options *opt;
+
 	opt = kmalloc(sizeof(struct ip_options)+((optlen+3)&~3), GFP_KERNEL);
 	if (!opt)
 		return -ENOMEM;
 	memset(opt, 0, sizeof(struct ip_options));
-	if (optlen && copy_from_user(opt->__data, data, optlen))
-		return -EFAULT;
+	if (optlen) {
+		if (user) {
+			if (copy_from_user(opt->__data, data, optlen))
+				return -EFAULT;
+		} else
+			memcpy(opt->__data, data, optlen);
+	}
 	while (optlen & 3)
 		opt->__data[optlen++] = IPOPT_END;
 	opt->optlen = optlen;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov