diff mbox series

[v2,1/2] rtld: Fix handling of '--' option

Message ID 20240726103351.3956251-1-henrik@lxm.se
State New
Headers show
Series [v2,1/2] rtld: Fix handling of '--' option | expand

Commit Message

Henrik Lindström July 26, 2024, 10:33 a.m. UTC
It always resulted in the error `unrecognized option '--'` previously.
---
 elf/rtld.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Adhemerval Zanella Netto July 30, 2024, 3:54 p.m. UTC | #1
On 26/07/24 07:33, Henrik Lindström wrote:
> It always resulted in the error `unrecognized option '--'` previously.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  elf/rtld.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/elf/rtld.c b/elf/rtld.c
> index bfdf632e77..7b982c5fe5 100644
> --- a/elf/rtld.c
> +++ b/elf/rtld.c
> @@ -1501,12 +1501,16 @@ dl_main (const ElfW(Phdr) *phdr,
>  	  _dl_version ();
>  	else if (_dl_argv[1][0] == '-' && _dl_argv[1][1] == '-')
>  	  {
> -	   if (_dl_argv[1][1] == '\0')
> -	     /* End of option list.  */
> -	     break;
> -	   else
> -	     /* Unrecognized option.  */
> -	     _dl_usage (ld_so_name, _dl_argv[1]);
> +	    if (_dl_argv[1][2] == '\0')
> +	      {
> +		/* End of option list.  */
> +		--_dl_argc;
> +		++_dl_argv;
> +		break;
> +	      }
> +	    else
> +	      /* Unrecognized option.  */
> +	      _dl_usage (ld_so_name, _dl_argv[1]);
>  	  }
>  	else
>  	  break;
diff mbox series

Patch

diff --git a/elf/rtld.c b/elf/rtld.c
index bfdf632e77..7b982c5fe5 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1501,12 +1501,16 @@  dl_main (const ElfW(Phdr) *phdr,
 	  _dl_version ();
 	else if (_dl_argv[1][0] == '-' && _dl_argv[1][1] == '-')
 	  {
-	   if (_dl_argv[1][1] == '\0')
-	     /* End of option list.  */
-	     break;
-	   else
-	     /* Unrecognized option.  */
-	     _dl_usage (ld_so_name, _dl_argv[1]);
+	    if (_dl_argv[1][2] == '\0')
+	      {
+		/* End of option list.  */
+		--_dl_argc;
+		++_dl_argv;
+		break;
+	      }
+	    else
+	      /* Unrecognized option.  */
+	      _dl_usage (ld_so_name, _dl_argv[1]);
 	  }
 	else
 	  break;