about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHenrik Lindström <henrik@lxm.se>2024-07-26 12:33:50 +0200
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-08-06 10:26:17 -0300
commit2227195794f96c7bf583e9ea4fb929cbedf1d8a1 (patch)
tree556edd0a59b0401b3e307bf9a488f4dc38f75476
parent942670c81dc8071dd75d6213e771daa5d2084cb6 (diff)
downloadglibc-2227195794f96c7bf583e9ea4fb929cbedf1d8a1.tar.gz
glibc-2227195794f96c7bf583e9ea4fb929cbedf1d8a1.tar.xz
glibc-2227195794f96c7bf583e9ea4fb929cbedf1d8a1.zip
rtld: Fix handling of '--' option
It always resulted in the error `unrecognized option '--'` previously.
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
-rw-r--r--elf/rtld.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 09b9c9993b..1e2e9ad5a8 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;