[PATCH v16 5/9] posix: do not allow option name translations for secure programs

Vivien Kraus vivien@planete-kraus.eu
Thu Oct 30 20:13:10 GMT 2025


SETUID / SETGID / AT_SECURE programs should not accept translated
names, so that the programmer knows exactly how the program can be
invoked.
---
 posix/getopt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/posix/getopt.c b/posix/getopt.c
index 28c8aa4bbf..6b235fa4e3 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -197,7 +197,7 @@ match_translated_option_name (char *(*translate) (const char *, const char *,
                               const char *opt_name)
 {
   const char *translated = opt_name;
-  if (translate)
+  if (translate != NULL && !__libc_enable_secure)
     translated = translate (opt_textdomain, translation_context, opt_name);
   return (!strncmp (translated, argument, argument_length)
           && argument_length == strlen (translated));
-- 
2.34.1



More information about the Libc-alpha mailing list