* [PATCH iproute2-next] ip: error out if iplink does not consume all options
@ 2023-07-28 18:33 Jakub Kicinski
2023-07-30 16:27 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2023-07-28 18:33 UTC (permalink / raw)
To: dsahern, stephen; +Cc: netdev, Jakub Kicinski
dummy does not define .parse_opt, which make ip ignore all
trailing arguments, for example:
# ip link add type dummy a b c d e f name cheese
will work just fine (and won't call the device "cheese").
Error out in this case with a clear error message:
# ip link add type dummy a b c d e f name cheese
Garbage instead of arguments "a ...". Try "ip link help".
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
ip/iplink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index 6c5d13d53a84..f60cff9c4b5f 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -1112,7 +1112,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
argc -= ret;
argv += ret;
- if (lu && argc) {
+ if (lu && lu->parse_opt && argc) {
struct rtattr *data;
data = addattr_nest(&req.n, sizeof(req), iflatype);
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH iproute2-next] ip: error out if iplink does not consume all options
2023-07-28 18:33 [PATCH iproute2-next] ip: error out if iplink does not consume all options Jakub Kicinski
@ 2023-07-30 16:27 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2023-07-30 16:27 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: dsahern, netdev
On Fri, 28 Jul 2023 11:33:29 -0700
Jakub Kicinski <kuba@kernel.org> wrote:
> dummy does not define .parse_opt, which make ip ignore all
> trailing arguments, for example:
>
> # ip link add type dummy a b c d e f name cheese
>
> will work just fine (and won't call the device "cheese").
> Error out in this case with a clear error message:
>
> # ip link add type dummy a b c d e f name cheese
> Garbage instead of arguments "a ...". Try "ip link help".
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Looks good, but then the latter check for lu->parse_opt in the if
clause is redundant. Coverity would flag that (assuming I get
Coverity running again on iproute).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-30 16:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 18:33 [PATCH iproute2-next] ip: error out if iplink does not consume all options Jakub Kicinski
2023-07-30 16:27 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox