diff mbox

ax25: cleanup a range test

Message ID 20131018090656.GA23528@longonot.mountain
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Dan Carpenter Oct. 18, 2013, 9:06 a.m. UTC
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>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller Oct. 18, 2013, 5:56 p.m. UTC | #1
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 18 Oct 2013 12:06:56 +0300

> 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>

Applied to net-next, thanks Dan.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 4b4d2b7..a00123e 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -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;
 		}