[PATCH v5 1/4] posix: allow getopt_long to match translated option names

Florian Weimer fweimer@redhat.com
Thu Jun 5 07:50:45 GMT 2025


* Vivien Kraus:

> +/* Return 1 iff a translation for opt_name has been found and it
> +   matches the substring from argument, length argument_length.
> +*/
> +static const int
> +match_translated_option_name (char *(*translate) (const char *msgid),
> +                              const char *argument, size_t argument_length,
> +                              const char *opt_name)
> +{
> +  const char *translated = opt_name;
> +  if (translate)
> +    translated = translate (opt_name);
> +  return (!strncmp (translated, argument, argument_length)
> +          && argument_length == strlen (translated));
> +}

This should probably use

  translate != NULL && !__libc_enable_secure

to stop accepting alternative option names for SUID/SGID/AT_SECURE
programs, to avoid introducing security vulnerabilities.

There is a hard-coded assumption of one possible translation, which
makes it impossible to improve translations without breaking workflows.

Thanks,
Florian



More information about the Libc-alpha mailing list