Fix argv overrun in getconf (bug 27761)
Commit Message
Correct argument counter accounting when processing the -v option with the
argument directly attached.
---
posix/getconf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
* Andreas Schwab:
> Correct argument counter accounting when processing the -v option with the
> argument directly attached.
Looks okay, thanks. Do we need to add a test? Probably not.
Florian
On Wed, Apr 21, 2021 at 7:20 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> Correct argument counter accounting when processing the -v option with the
> argument directly attached.
> ---
> posix/getconf.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/posix/getconf.c b/posix/getconf.c
> index efc9623b3b..4dccc9cbf2 100644
> --- a/posix/getconf.c
> +++ b/posix/getconf.c
> @@ -519,7 +519,7 @@ environment SPEC.\n\n"));
> else
> {
> argv += 1;
> - argc += 1;
> + argc -= 1;
> }
> }
> #else
> @@ -544,7 +544,7 @@ environment SPEC.\n\n"));
> {
> spec = &argv[1][2];
> argv += 1;
> - argc += 1;
> + argc -= 1;
> }
> }
> else
> --
> 2.31.1
>
LGTM.
Thanks.
@@ -519,7 +519,7 @@ environment SPEC.\n\n"));
else
{
argv += 1;
- argc += 1;
+ argc -= 1;
}
}
#else
@@ -544,7 +544,7 @@ environment SPEC.\n\n"));
{
spec = &argv[1][2];
argv += 1;
- argc += 1;
+ argc -= 1;
}
}
else