I'm still facing the same issue. Further investigations showed the cause
for the segfault due to absolutely no checking for null pointers. Thus
it fails when trying to duplicate a string with mc_strdup().

Further check shows that it fails to locale definition of LC_ALL=
without any value, which AFAIK is a kind of default, at least on debian
or on my system.

> $ locale
> LANG=en_US.utf8
> LANGUAGE=en_US:en
> LC_CTYPE=en_US.utf8
> LC_NUMERIC=de_DE.utf8
> LC_TIME=de_DE.utf8
> LC_COLLATE=en_US.utf8
> LC_MONETARY=de_DE.utf8
> LC_MESSAGES=en_US.utf8
> LC_PAPER=de_DE.utf8
> LC_NAME=de_DE.utf8
> LC_ADDRESS=de_DE.utf8
> LC_TELEPHONE=de_DE.utf8
> LC_MEASUREMENT=de_DE.utf8
> LC_IDENTIFICATION=de_DE.utf8
> LC_ALL=

This is not accounted for in the code of check of the character set

> char *
> util_get_charset (void)
> {
>   char *charset;
> 
>   if (mailvar_get (&charset, "charset", mailvar_type_string, 0))
>     return NULL;
> 
>   if (mu_c_strcasecmp (charset, "auto") == 0)
>     {
>       struct mu_lc_all lc_all = { .flags = 0 };
>       char *tmp = getenv ("LC_ALL");
>       if (!tmp)
>       tmp = getenv ("LANG");
>       
>       if (tmp && mu_parse_lc_all (tmp, &lc_all, MU_LC_CSET) == 0)
>       {
>         charset = mu_strdup (lc_all.charset);
>         mu_lc_all_free (&lc_all);
>       }
>       else
>       charset = NULL;
>     }
>   else
>     charset = mu_strdup (charset);
> 
>   return charset;
> }

Thus a patch would be to add a check for empty string of LC_ALL

>       if ((!tmp) | ((tmp != NULL) & (strlen(tmp) == 0)) )
>       tmp = getenv ("LANG");


I don't know if this is the best way how to fix this issue. But having a
LC_ALL which is empty seems to be valid for me.



-- 
Dipl.-Ing. Jochen Betz
jochen.b...@gmx.net
--- org.c	2020-11-13 12:48:03.489782343 +0100
+++ patched.c	2020-11-13 12:46:56.616695250 +0100
@@ -1059,7 +1059,7 @@
     {
       struct mu_lc_all lc_all = { .flags = 0 };
       char *tmp = getenv ("LC_ALL");
-      if (!tmp)
+      if ((!tmp) | ((tmp != NULL) & (strlen(tmp) == 0)) )
 	tmp = getenv ("LANG");
       
       if (tmp && mu_parse_lc_all (tmp, &lc_all, MU_LC_CSET) == 0)

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to