Re: [PATCH] mcstrans: match base classification and word text case-insensitively

Stephen Smalley <[email protected]> Tue, 21 Jul 2026 08:54:00 -0400
Newsgroups org.kernel.vger.selinux
Message-ID <CAEjxPJ6WzreWdVMBPz5zZu8LYdBUSK31UMYGTgiR-RvTvz7Aog@mail.gmail.com>
On Thu, Jul 16, 2026 at 3:57 PM Stephen Smalley
<[email protected]> wrote:
>
> The base classification and word regexes are compiled with
> PCRE2_CASELESS so a differently cased input matches the regex, but the
> extracted substring is then compared against the configured text with
> strcmp/strncmp() and fails.
>
> Use strcasecmp()/strncasecmp() so the follow-up lookup is consistent
> with the caseless regex.
>
> Signed-off-by: Stephen Smalley <[email protected]>

Merged.

> ---
>  mcstrans/src/mcstrans.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
> index 8ed1aa95..89235269 100644
> --- a/mcstrans/src/mcstrans.c
> +++ b/mcstrans/src/mcstrans.c
> @@ -1285,7 +1285,7 @@ static char *compute_raw_from_trans(const char *level, domain_t *domain)
>                           match, strlen(match));
>                 base_classification_t *bc;
>                 for (bc = domain->base_classifications; bc; bc = bc->next) {
> -                       if (!strcmp(bc->trans, match)) {
> +                       if (!strcasecmp(bc->trans, match)) {
>                                 log_debug(
>                                         " compute_raw_from_trans base classification %s matched %s\n",
>                                         level, bc->trans);
> @@ -1443,7 +1443,7 @@ static char *compute_raw_from_trans(const char *level, domain_t *domain)
>                                                                 int wlen = strlen(
>                                                                         w->text);
>                                                                 if (plen >= wlen &&
> -                                                                   !strncmp(
> +                                                                   !strncasecmp(
>                                                                             w->text,
>                                                                             p,
>                                                                             strlen(w->text))) {
> --
> 2.55.0
>