patch-2.1.27 linux/net/x25/af_x25.c

Next file: linux/net/x25/x25_in.c
Previous file: linux/net/unix/af_unix.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.26/linux/net/x25/af_x25.c linux/net/x25/af_x25.c
@@ -328,7 +328,7 @@
 		kfree_skb(skb, FREE_READ);
 	}
 
-	if (sk->wmem_alloc || sk->rmem_alloc) {	/* Defer: outstanding buffers */
+	if (sk->wmem_alloc != 0 || sk->rmem_alloc != 0) {	/* Defer: outstanding buffers */
 		init_timer(&sk->timer);
 		sk->timer.expires  = jiffies + 10 * HZ;
 		sk->timer.function = x25_destroy_timer;
@@ -355,21 +355,18 @@
 	int err, opt;
 
 	if (level != SOL_X25)
-		return -EOPNOTSUPP;
+		return -ENOPROTOOPT;
 
-	if (optval == NULL)
-		return -EINVAL;
-
-	if ((err = verify_area(VERIFY_READ, optval, sizeof(int))) != 0)
-		return err;
-
-	get_user(opt, (int *)optval);
+	if(optlen<sizeof(int))
+		return-EINVAL;
+	if(get_user(opt, (int *)optval))
+		return -EFAULT;
 
-	switch (optname) {
+	switch (optname) 
+	{
 		case X25_QBITINCL:
 			sk->protinfo.x25->qbitincl = opt ? 1 : 0;
 			return 0;
-
 		default:
 			return -ENOPROTOOPT;
 	}
@@ -380,12 +377,16 @@
 {
 	struct sock *sk = sock->sk;
 	int val = 0;
-	int err; 
-
+	int len; 
+	
 	if (level != SOL_X25)
-		return -EOPNOTSUPP;
+		return -ENOPROTOOPT;
 
-	switch (optname) {
+	if(get_user(len,optlen))
+		return -EFAULT;
+		
+	switch (optname) 
+	{
 		case X25_QBITINCL:
 			val = sk->protinfo.x25->qbitincl;
 			break;
@@ -394,16 +395,11 @@
 			return -ENOPROTOOPT;
 	}
 
-	if ((err = verify_area(VERIFY_WRITE, optlen, sizeof(int))) != 0)
-		return err;
-
-	put_user(sizeof(int), (unsigned long *)optlen);
-
-	if ((err = verify_area(VERIFY_WRITE, optval, sizeof(int))) != 0)
-		return err;
-
-	put_user(val, (unsigned long *)optval);
-
+	len=min(len,sizeof(int));
+	if(put_user(len, optlen))
+		return -EFAULT;
+	if(copy_to_user(optval,&val,len))
+		return -EFAULT;
 	return 0;
 }
 
@@ -548,15 +544,6 @@
 			x25_destroy_socket(sk);
 			break;
 
-		case X25_STATE_1:
-			sk->protinfo.x25->state = X25_STATE_0;
-			sk->state               = TCP_CLOSE;
-			sk->shutdown           |= SEND_SHUTDOWN;
-			sk->state_change(sk);
-			sk->dead                = 1;
-			x25_destroy_socket(sk);
-			break;
-
 		case X25_STATE_2:
 			sk->protinfo.x25->state = X25_STATE_0;
 			sk->state               = TCP_CLOSE;
@@ -566,6 +553,7 @@
 			x25_destroy_socket(sk);
 			break;			
 
+		case X25_STATE_1:
 		case X25_STATE_3:
 		case X25_STATE_4:
 			x25_clear_queues(sk);

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