Fix argv overrun in getconf (bug 27761)

Message ID 87a6prbxu7.fsf@igel.home
State New
Headers show
Series
  • Fix argv overrun in getconf (bug 27761)
Related show

Commit Message

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

-- 
2.31.1


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Comments

Adhemerval Zanella via Libc-alpha April 21, 2021, 1:08 p.m. | #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
Adhemerval Zanella via Libc-alpha April 21, 2021, 2:28 p.m. | #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.

-- 
H.J.

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