From 61c410b68b75fb15b0270d08b92f4fbc0f0ef078 Mon Sep 17 00:00:00 2001 From: iefa m Date: Tue, 27 Oct 2026 06:31:13 +0530 Subject: [PATCH] read_env_file: remove filtered entries from the g/c list before freeing env_file_next_local() adds each line it returns to the sudoers garbage collection list. When read_env_file() drops a restricted_env_file entry that is not allowed by env_keep/env_check (or is matched by env_delete), it frees the string but leaves it on the g/c list, so sudoers_gc_run() frees it a second time when the plugin is closed. This only affects builds with NO_LEAKS defined (--disable-leaks, --enable-sanitizer and the fuzzers). --- plugins/sudoers/env.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/sudoers/env.c b/plugins/sudoers/env.c index 989f17b2bd..30e241378f 100644 --- a/plugins/sudoers/env.c +++ b/plugins/sudoers/env.c @@ -1390,6 +1390,7 @@ read_env_file(const struct sudoers_context *ctx, const char *path, */ if (restricted) { if (def_env_reset ? !env_should_keep(ctx, envstr) : env_should_delete(envstr)) { + sudoers_gc_remove(GC_PTR, envstr); free(envstr); continue; }