1
0
mirror of https://passt.top/passt synced 2024-07-01 23:42:41 +00:00

conf: Fix getopt_long() optstring for current semantics of -D, -S, -p

Declaring them as required_argument in the longopts array specifies
validation, but doesn't affect how optind is increased after parsing
their values.

Currently, passing one of these options as last option causes pasta
to handle their own values as path to a binary to execute.

Fixes: aae2a9bbf7 ("conf: Use "-D none" and "-S none" instead of missing empty option arguments")
Fixes: bf95322fc1 ("conf: Make the argument to --pcap option mandatory")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2022-09-02 16:49:23 +02:00
parent a1c38ffe0a
commit bac7dfebe4

4
conf.c
View File

@ -1094,9 +1094,9 @@ void conf(struct ctx *c, int argc, char **argv)
const char *optstring;
if (c->mode == MODE_PASST)
optstring = "dqfehs:p::P:m:a:n:M:g:i:D::S::46t:u:";
optstring = "dqfehs:p:P:m:a:n:M:g:i:D:S:46t:u:";
else
optstring = "dqfehI:p::P:m:a:n:M:g:i:D::S::46t:u:T:U:";
optstring = "dqfehI:p:P:m:a:n:M:g:i:D:S:46t:u:T:U:";
name = getopt_long(argc, argv, optstring, options, NULL);