git: c38df24407d1 - stable/13 - rtld: fixes for handling of the grouped options

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 16 Apr 2023 11:12:03 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=c38df24407d1fcafb0c805db919315136a93c95a

commit c38df24407d1fcafb0c805db919315136a93c95a
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-04-13 04:47:23 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-04-16 11:11:35 +0000

    rtld: fixes for handling of the grouped options
    
    (cherry picked from commit 7cdfe51f30965a365e3e7c829396a56e2a7e5141)
---
 libexec/rtld-elf/rtld.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 8e2cd0dfcb24..30cb4b595b71 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -6078,13 +6078,16 @@ parse_args(char* argv[], int argc, bool *use_pathp, int *fdp,
 					_rtld_error("Both -b and -f specified");
 					rtld_die();
 				}
+				if (j != arglen - 1) {
+					_rtld_error("Invalid options: %s", arg);
+					rtld_die();
+				}
 				i++;
 				*argv0 = argv[i];
 				seen_b = true;
 				break;
 			} else if (opt == 'd') {
 				*dir_ignore = true;
-				break;
 			} else if (opt == 'f') {
 				if (seen_b) {
 					_rtld_error("Both -b and -f specified");
@@ -6099,7 +6102,8 @@ parse_args(char* argv[], int argc, bool *use_pathp, int *fdp,
 				 * name but the descriptor is what
 				 * will actually be executed).
 				 *
-				 * -f must be the last option in, e.g., -abcf.
+				 * -f must be the last option in the
+				 * group, e.g., -abcf <fd>.
 				 */
 				if (j != arglen - 1) {
 					_rtld_error("Invalid options: %s", arg);