git: ef2694f368ce - main - rtld direct exec: make -u behavior match the description

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 30 Apr 2024 00:55:05 UTC
The branch main has been updated by kib:

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

commit ef2694f368cee5957ee44b0298da88ff8360d561
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-28 20:57:54 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-30 00:26:49 +0000

    rtld direct exec: make -u behavior match the description
    
    Instead of only ignoring insecure env vars, clear them all.
    
    Reviewed by:    emaste, markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D44999
---
 libexec/rtld-elf/rtld.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index f5a2eeb37f10..5743bbdd6f61 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -6189,7 +6189,10 @@ parse_args(char* argv[], int argc, bool *use_pathp, int *fdp,
 			} else if (opt == 'p') {
 				*use_pathp = true;
 			} else if (opt == 'u') {
-				trust = false;
+				u_int ll;
+
+				for (ll = 0; ll < nitems(ld_env_vars); ll++)
+					ld_env_vars[ll].val = NULL;
 			} else if (opt == 'v') {
 				machine[0] = '\0';
 				mib[0] = CTL_HW;