* [PATCH] dns: remove redundant zero length namelen check
@ 2019-04-09 12:59 ` Colin King
0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2019-04-09 12:59 UTC (permalink / raw)
To: David S . Miller, David Howells, netdev; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The zero namelen check is redundant as it has already been checked
for zero at the start of the function. Remove the redundant check.
Addresses-Coverity: ("Logically Dead Code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/dns_resolver/dns_query.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c
index 76338c38738a..19aa32fc1802 100644
--- a/net/dns_resolver/dns_query.c
+++ b/net/dns_resolver/dns_query.c
@@ -94,8 +94,6 @@ int dns_query(const char *type, const char *name, size_t namelen,
desclen += typelen + 1;
}
- if (!namelen)
- namelen = strnlen(name, 256);
if (namelen < 3 || namelen > 255)
return -EINVAL;
desclen += namelen + 1;
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] dns: remove redundant zero length namelen check
@ 2019-04-09 12:59 ` Colin King
0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2019-04-09 12:59 UTC (permalink / raw)
To: David S . Miller, David Howells, netdev; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The zero namelen check is redundant as it has already been checked
for zero at the start of the function. Remove the redundant check.
Addresses-Coverity: ("Logically Dead Code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/dns_resolver/dns_query.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c
index 76338c38738a..19aa32fc1802 100644
--- a/net/dns_resolver/dns_query.c
+++ b/net/dns_resolver/dns_query.c
@@ -94,8 +94,6 @@ int dns_query(const char *type, const char *name, size_t namelen,
desclen += typelen + 1;
}
- if (!namelen)
- namelen = strnlen(name, 256);
if (namelen < 3 || namelen > 255)
return -EINVAL;
desclen += namelen + 1;
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] dns: remove redundant zero length namelen check
2019-04-09 12:59 ` Colin King
@ 2019-04-11 21:02 ` David Miller
-1 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-04-11 21:02 UTC (permalink / raw)
To: colin.king; +Cc: dhowells, netdev, kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Tue, 9 Apr 2019 13:59:12 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> The zero namelen check is redundant as it has already been checked
> for zero at the start of the function. Remove the redundant check.
>
> Addresses-Coverity: ("Logically Dead Code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied to net-next.
However it does look like two sets of semantics were considered.
In one case rejecting a zero namelen and in another having it
mean whatever the strings length is modulo the max of 256.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dns: remove redundant zero length namelen check
@ 2019-04-11 21:02 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-04-11 21:02 UTC (permalink / raw)
To: colin.king; +Cc: dhowells, netdev, kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Tue, 9 Apr 2019 13:59:12 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> The zero namelen check is redundant as it has already been checked
> for zero at the start of the function. Remove the redundant check.
>
> Addresses-Coverity: ("Logically Dead Code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied to net-next.
However it does look like two sets of semantics were considered.
In one case rejecting a zero namelen and in another having it
mean whatever the strings length is modulo the max of 256.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dns: remove redundant zero length namelen check
2019-04-09 12:59 ` Colin King
@ 2019-04-12 10:19 ` David Howells
-1 siblings, 0 replies; 6+ messages in thread
From: David Howells @ 2019-04-12 10:19 UTC (permalink / raw)
To: David Miller; +Cc: dhowells, colin.king, netdev, kernel-janitors, linux-kernel
David Miller <davem@davemloft.net> wrote:
> > The zero namelen check is redundant as it has already been checked
> > for zero at the start of the function. Remove the redundant check.
> >
> > Addresses-Coverity: ("Logically Dead Code")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Applied to net-next.
>
> However it does look like two sets of semantics were considered.
> In one case rejecting a zero namelen and in another having it
> mean whatever the strings length is modulo the max of 256.
It probably makes sense to merge the:
if (namelen < 3 || namelen > 255)
return -EINVAL;
check into the earlier:
if (!name || namelen == 0)
return -EINVAL;
check too.
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dns: remove redundant zero length namelen check
@ 2019-04-12 10:19 ` David Howells
0 siblings, 0 replies; 6+ messages in thread
From: David Howells @ 2019-04-12 10:19 UTC (permalink / raw)
To: David Miller; +Cc: dhowells, colin.king, netdev, kernel-janitors, linux-kernel
David Miller <davem@davemloft.net> wrote:
> > The zero namelen check is redundant as it has already been checked
> > for zero at the start of the function. Remove the redundant check.
> >
> > Addresses-Coverity: ("Logically Dead Code")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Applied to net-next.
>
> However it does look like two sets of semantics were considered.
> In one case rejecting a zero namelen and in another having it
> mean whatever the strings length is modulo the max of 256.
It probably makes sense to merge the:
if (namelen < 3 || namelen > 255)
return -EINVAL;
check into the earlier:
if (!name || namelen = 0)
return -EINVAL;
check too.
David
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-04-12 10:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09 12:59 [PATCH] dns: remove redundant zero length namelen check Colin King
2019-04-09 12:59 ` Colin King
2019-04-11 21:02 ` David Miller
2019-04-11 21:02 ` David Miller
2019-04-12 10:19 ` David Howells
2019-04-12 10:19 ` David Howells
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.