Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail Content-Type fallback to US_ASCII fails #1

Open
tlhackque opened this issue Nov 3, 2022 · 1 comment
Open

Mail Content-Type fallback to US_ASCII fails #1

tlhackque opened this issue Nov 3, 2022 · 1 comment

Comments

@tlhackque
Copy link

In cron.c, line 104 we have:

setlocale(LC_COLLATE, "C"); /* Except for collation, since load_database() uses a-z */
       /* Except that "US-ASCII" is preferred to "ANSI_x3.4-1968" in MIME,
        * even though "ANSI_x3.4-1968" is the official charset name. */
       if ( ( cs = nl_langinfo( CODESET ) ) != 0L && 
               strcmp(cs, "ANSI_x3.4-1968") != 0 )
           strncpy( cron_default_mail_charset, cs, MAX_ENVSTR );
       else
           strcpy( cron_default_mail_charset, "US-ASCII" );

But nl_langinfo() can return ANSI_X3.4-1968. Note the upper-case 'X'. This results in cron_default_mail_charset acquiring that value instead of the intended US-ASCII.

It's not clear whether any environment returns the lower-case 'x', but the simplest fix is to replace strcmp with the case-insensitive strcasecmp(3). (strings.h or string.h)

You can demonstrate this with the following Perl on-liner (Perl exposes the same APIs):

$  perl -MPOSIX -MI18N::Langinfo=langinfo,CODESET -e'setlocale(LC_ALL,"fr_FRX");print langinfo(CODESET),"\n";'
ANSI_X3.4-1968
$

In my case, on Linux 5.17.12-100.fc34.x86_64, Perl v5.32.1; fr_FRX is not a defined locale.

@tlhackque
Copy link
Author

tlhackque commented Nov 3, 2022

Wrong, repo, sorry. See vixie/cron#10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant