This is a longstanding bug which I finally got round to looking at,
rather than just installing BSD mail.
I have the following locale, which is what you get for British English
on Debian; I assume other locales are similarly defined.
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
With that, mail(1) SEGVs if I run it to read messages:
#0 0x00007ffff7d60ad8 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff7c78f2f in strdup () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff7e82e4e in mu_strdup (s=0x0) at alloc.c:76
#3 0x0000555555579365 in util_get_charset () at util.c:1231
#4 0x00005555555793bb in util_rfc2047_decode (value=0x7fffffffda58) at
util.c:1251
#5 0x0000555555566d66 in sender_string (msg=0x555555597f90) at from.c:272
#6 0x0000555555566ddb in hdr_from (args=0x7fffffffdac0, data=0x0) at
from.c:290
#7 0x000055555556678c in format_headline (seg=0x55555558d670,
mspec=0x555555597e20, msg=0x555555597f90) at from.c:96
#8 0x000055555556796f in mail_from0 (mspec=0x555555597e20,
msg=0x555555597f90,
data=0x0) at from.c:615
#9 0x0000555555570002 in page_do (func=0x555555567941 <mail_from0>, data=0x0)
at page.c:181
#10 0x00005555555679e3 in mail_headers (argc=1, argv=0x5555555af868)
at headers.c:34
#11 0x000055555557716d in util_do_command (fmt=0x55555557bf02 "headers")
at util.c:144
#12 0x000055555556920f in main (argc=0, argv=0x7fffffffe020) at mail.c:698
This patch fixes it.
diff -rN -u old-mailutils-3.15/mail/util.c new-mailutils-3.15/mail/util.c
--- old-mailutils-3.15/mail/util.c 2023-02-20 14:10:45.412646572 +0000
+++ new-mailutils-3.15/mail/util.c 2023-02-20 14:10:45.412646572 +0000
@@ -1223,12 +1223,15 @@
{
struct mu_lc_all lc_all = { .flags = 0 };
char *tmp = getenv ("LC_ALL");
- if (!tmp)
+ if (!tmp || !strlen (tmp))
tmp = getenv ("LANG");
if (tmp && mu_parse_lc_all (tmp, &lc_all, MU_LC_CSET) == 0)
{
- charset = mu_strdup (lc_all.charset);
+ if (lc_all.charset)
+ charset = mu_strdup (lc_all.charset);
+ else
+ charset = NULL;
mu_lc_all_free (&lc_all);
}
else