diff mbox series

Fix argv overrun in getconf (bug 27761)

Message ID 87a6prbxu7.fsf@igel.home
State Committed
Commit b59c6989814f7ac966ee702789b34f32a1439aaf
Headers show
Series Fix argv overrun in getconf (bug 27761) | expand

Commit Message

Andreas Schwab April 21, 2021, 12:56 p.m. UTC
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

Florian Weimer April 21, 2021, 1:08 p.m. UTC | #1
* 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
H.J. Lu April 21, 2021, 2:28 p.m. UTC | #2
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.
diff mbox series

Patch

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