]> git.ipfire.org Git - thirdparty/iptables.git/commit
Proper fix for "unknown argument" error message
authorPhil Sutter <phil@nwl.cc>
Wed, 25 Jan 2023 00:51:43 +0000 (01:51 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 31 Jan 2023 15:29:26 +0000 (16:29 +0100)
commitd6eb6a9fd3878ce4fa01f8d4127f1735988bd07b
tree7e61e5935cbc00827b34069ce61ef21c93eeb653
parentca8fb6c21b298b3d96db2bfbf9c74d393bdd4728
Proper fix for "unknown argument" error message

While commit 1b8210f848631 kind of fixed the corner-case of invalid
short-options packed with others, it broke error reporting for
long-options. Revert it and deploy a proper solution:

When passing an invalid short-option, e.g. 'iptables -vaL', getopt_long
sets the variable 'optopt' to the invalid character's value. Use it for
reporting instead of optind if set.

To distinguish between invalid options and missing option arguments,
ebtables-translate optstring needs adjustment.

Fixes: 1b8210f848631 ("ebtables: Fix error message for invalid parameters")
Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/tests/shell/testcases/iptables/0009-unknown-arg_0 [new file with mode: 0755]
iptables/xshared.c
iptables/xtables-eb-translate.c
iptables/xtables-eb.c