* [PATCH] conf: Fix getopt_long() optstring for current semantics of -D, -S, -p
@ 2022-09-02 14:55 Stefano Brivio
2022-09-03 9:32 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2022-09-02 14:55 UTC (permalink / raw)
To: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]
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: aae2a9bbf7d1 ("conf: Use "-D none" and "-S none" instead of missing empty option arguments")
Fixes: bf95322fc1ef ("conf: Make the argument to --pcap option mandatory")
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
conf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/conf.c b/conf.c
index e6d1c62..2edb4ae 100644
--- a/conf.c
+++ b/conf.c
@@ -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);
--
@@ -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);
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] conf: Fix getopt_long() optstring for current semantics of -D, -S, -p
2022-09-02 14:55 [PATCH] conf: Fix getopt_long() optstring for current semantics of -D, -S, -p Stefano Brivio
@ 2022-09-03 9:32 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2022-09-03 9:32 UTC (permalink / raw)
To: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1648 bytes --]
On Fri, Sep 02, 2022 at 04:55:50PM +0200, Stefano Brivio wrote:
> 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: aae2a9bbf7d1 ("conf: Use "-D none" and "-S none" instead of missing empty option arguments")
> Fixes: bf95322fc1ef ("conf: Make the argument to --pcap option mandatory")
> Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
Oh, bother. I remember realizing that I needed to make that change
while I was working on the patch... then forgetting to actually do so.
Reviewed-by: David Gibson <david(a)gibson.dropbear.id.au>
> ---
> conf.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/conf.c b/conf.c
> index e6d1c62..2edb4ae 100644
> --- a/conf.c
> +++ b/conf.c
> @@ -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);
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-03 9:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 14:55 [PATCH] conf: Fix getopt_long() optstring for current semantics of -D, -S, -p Stefano Brivio
2022-09-03 9:32 ` David Gibson
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).