From 9002c7c56f76eccc414779dbfc3cb1ca4e7ea149 Mon Sep 17 00:00:00 2001 From: iefa m Date: Fri, 16 Oct 2026 02:13:04 +0530 Subject: [PATCH] script_matches: don't report a match when the interpreter differs --- src/exec_ptrace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/exec_ptrace.c b/src/exec_ptrace.c index 3a6355d629..ab68facd94 100644 --- a/src/exec_ptrace.c +++ b/src/exec_ptrace.c @@ -1489,6 +1489,7 @@ script_matches(const char *script, const char *execpath, int argc, char magic[2]; int count; FILE *fp = NULL; + bool matched = false; ssize_t len; debug_decl(get_interpreter, SUDO_DEBUG_EXEC); @@ -1557,6 +1558,7 @@ script_matches(const char *script, const char *execpath, int argc, continue; } } + goto done; } if (argc > 1 && interp_args != NULL) { if (strcmp(interp_args, argv[1]) != 0) { @@ -1568,6 +1570,7 @@ script_matches(const char *script, const char *execpath, int argc, argv++; } argv++; + matched = true; break; } @@ -1575,7 +1578,7 @@ script_matches(const char *script, const char *execpath, int argc, free(line); if (fp != NULL) fclose(fp); - debug_return_int((int)(argv - orig_argv)); + debug_return_int(matched ? (int)(argv - orig_argv) : 0); } static ssize_t