* [PATCH] net: Cleanup redundant tests on unsigned
@ 2009-10-23 15:59 Roel Kluin
2009-10-29 8:40 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2009-10-23 15:59 UTC (permalink / raw)
To: David S. Miller, netdev, Andrew Morton
optlen is unsigned so the `< 0' test is never true.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
net/can/raw.c | 2 --
net/compat.c | 3 ---
net/ipv4/ip_sockglue.c | 2 +-
3 files changed, 1 insertions(+), 6 deletions(-)
Or should the tests in net/can/raw.c or net/compat.c
be replaced by something else?
diff --git a/net/can/raw.c b/net/can/raw.c
index b5e8979..9e18c2a 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -424,8 +424,6 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (level != SOL_CAN_RAW)
return -EINVAL;
- if (optlen < 0)
- return -EINVAL;
switch (optname) {
diff --git a/net/compat.c b/net/compat.c
index a407c3a..e373995 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -390,9 +390,6 @@ asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
int err;
struct socket *sock;
- if (optlen < 0)
- return -EINVAL;
-
if ((sock = sockfd_lookup(fd, &err))!=NULL)
{
err = security_socket_setsockopt(sock,level,optname);
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index e982b5c..15dbf30 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -480,7 +480,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
case IP_OPTIONS:
{
struct ip_options *opt = NULL;
- if (optlen > 40 || optlen < 0)
+ if (optlen > 40)
goto e_inval;
err = ip_options_get_from_user(sock_net(sk), &opt,
optval, optlen);
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] net: Cleanup redundant tests on unsigned
@ 2009-10-23 15:21 Roel Kluin
2009-10-29 8:40 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2009-10-23 15:21 UTC (permalink / raw)
To: David S. Miller, netdev, Henner Eisen, linux-x25, Andrew Morton
If there is data, the unsigned skb->len is greater than 0.
rt.sigdigits is unsigned as well, so the test `>= 0' is
always true, the other part of the test catches wrapped
values.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
net/x25/x25_in.c | 2 +-
net/x25/x25_route.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/x25/x25_in.c b/net/x25/x25_in.c
index 7d7c3ab..96d9227 100644
--- a/net/x25/x25_in.c
+++ b/net/x25/x25_in.c
@@ -114,7 +114,7 @@ static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametyp
/*
* Copy any Call User Data.
*/
- if (skb->len >= 0) {
+ if (skb->len > 0) {
skb_copy_from_linear_data(skb,
x25->calluserdata.cuddata,
skb->len);
diff --git a/net/x25/x25_route.c b/net/x25/x25_route.c
index 2c999cc..66961ea 100644
--- a/net/x25/x25_route.c
+++ b/net/x25/x25_route.c
@@ -190,7 +190,7 @@ int x25_route_ioctl(unsigned int cmd, void __user *arg)
goto out;
rc = -EINVAL;
- if (rt.sigdigits < 0 || rt.sigdigits > 15)
+ if (rt.sigdigits > 15)
goto out;
dev = x25_dev_get(rt.device);
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] net: Cleanup redundant tests on unsigned
2009-10-23 15:21 Roel Kluin
@ 2009-10-29 8:40 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-10-29 8:40 UTC (permalink / raw)
To: roel.kluin; +Cc: netdev, eis, linux-x25, akpm
From: Roel Kluin <roel.kluin@gmail.com>
Date: Fri, 23 Oct 2009 17:21:56 +0200
> If there is data, the unsigned skb->len is greater than 0.
>
> rt.sigdigits is unsigned as well, so the test `>= 0' is
> always true, the other part of the test catches wrapped
> values.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-29 8:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-23 15:59 [PATCH] net: Cleanup redundant tests on unsigned Roel Kluin
2009-10-29 8:40 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2009-10-23 15:21 Roel Kluin
2009-10-29 8:40 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).