ax25: cleanup a range test
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 18 Oct 2013 09:06:56 +0000 (12:06 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Oct 2013 17:56:07 +0000 (13:56 -0400)
The current test works fine in practice.  The "amount" variable is
actually used as a boolean so negative values or any non-zero values
count as "true".  However since we don't allow numbers greater than one,
let's not allow negative numbers either.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ax25/af_ax25.c

index 4b4d2b779ec1a08202303863fea1b74c67f04383..a00123ebb0ae0705c8e45e8433a07e96a2a06fe5 100644 (file)
@@ -1735,7 +1735,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        res = -EFAULT;
                        break;
                }
-               if (amount > AX25_NOUID_BLOCK) {
+               if (amount < 0 || amount > AX25_NOUID_BLOCK) {
                        res = -EINVAL;
                        break;
                }