]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/netrom/af_netrom.c
Merge branch 'for-linville' of git://github.com/kvalo/ath6kl
[karo-tx-linux.git] / net / netrom / af_netrom.c
index 732152f718e0dceb36826e7c4f36935c20ef603b..7dab229bfbcca3c67aa6112ec4a19a40c411adcb 100644 (file)
@@ -306,26 +306,26 @@ static int nr_setsockopt(struct socket *sock, int level, int optname,
 {
        struct sock *sk = sock->sk;
        struct nr_sock *nr = nr_sk(sk);
-       int opt;
+       unsigned long opt;
 
        if (level != SOL_NETROM)
                return -ENOPROTOOPT;
 
-       if (optlen < sizeof(int))
+       if (optlen < sizeof(unsigned int))
                return -EINVAL;
 
-       if (get_user(opt, (int __user *)optval))
+       if (get_user(opt, (unsigned int __user *)optval))
                return -EFAULT;
 
        switch (optname) {
        case NETROM_T1:
-               if (opt < 1)
+               if (opt < 1 || opt > ULONG_MAX / HZ)
                        return -EINVAL;
                nr->t1 = opt * HZ;
                return 0;
 
        case NETROM_T2:
-               if (opt < 1)
+               if (opt < 1 || opt > ULONG_MAX / HZ)
                        return -EINVAL;
                nr->t2 = opt * HZ;
                return 0;
@@ -337,13 +337,13 @@ static int nr_setsockopt(struct socket *sock, int level, int optname,
                return 0;
 
        case NETROM_T4:
-               if (opt < 1)
+               if (opt < 1 || opt > ULONG_MAX / HZ)
                        return -EINVAL;
                nr->t4 = opt * HZ;
                return 0;
 
        case NETROM_IDLE:
-               if (opt < 0)
+               if (opt > ULONG_MAX / (60 * HZ))
                        return -EINVAL;
                nr->idle = opt * 60 * HZ;
                return 0;
@@ -1244,7 +1244,8 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
        case SIOCADDRT:
        case SIOCDELRT:
        case SIOCNRDECOBS:
-               if (!capable(CAP_NET_ADMIN)) return -EPERM;
+               if (!capable(CAP_NET_ADMIN))
+                       return -EPERM;
                return nr_rt_ioctl(cmd, argp);
 
        default: