After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 760304 - fix crash when invalid locale is found.
fix crash when invalid locale is found.
Status: RESOLVED FIXED
Product: gnome-desktop
Classification: Core
Component: libgnome-desktop
3.19.x
Other FreeBSD
: Normal normal
: ---
Assigned To: Desktop Maintainers
Desktop Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-01-08 00:55 UTC by Koop Mast (kwm)
Modified: 2016-01-11 13:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix sigsegv crash (1.17 KB, patch)
2016-01-08 00:55 UTC, Koop Mast (kwm)
none Details | Review
gnome-languages: Return early if the locale didn't parse correctly (1.95 KB, patch)
2016-01-08 14:06 UTC, Rui Matos
committed Details | Review
check if language is !NULL (1.03 KB, patch)
2016-01-11 10:04 UTC, Koop Mast (kwm)
committed Details | Review

Description Koop Mast (kwm) 2016-01-08 00:55:01 UTC
Created attachment 318447 [details] [review]
fix sigsegv crash

When a invalid locale is detected like "kk_Cyrl_KZ.UTF-8" in
gnome_parse_locale(), language is not set. construct_language_name()
will then try to access elements in language that don't exist, check
if language is !NULL before doing this, like territory, codeset and
modifier doing.

(lldb) s

(gnome-control-center:249): GnomeDesktop-WARNING **: locale 'kk_Cyrl_KZ.UTF-8' isn't valid

Process 249 stopped
* thread #1: tid = 102670, 0x0000000804756c2f libgnome-desktop-3.so.12`construct_language_name(language=0x0000000000000000, territory=0x0000000000000000, codeset=0x0000000000000000, modifier=0x0000000000000000) + 31 at gnome-languages.c:232, stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x0000000804756c2f libgnome-desktop-3.so.12`construct_language_name(language=0x0000000000000000, territory=0x0000000000000000, codeset=0x0000000000000000, modifier=0x0000000000000000) + 31 at gnome-languages.c:232
   229 	{
   230 	        char *name;
   231 	
-> 232 	        g_assert (language[0] != 0);
   233 	        g_assert (territory == NULL || territory[0] != 0);
   234 	        g_assert (codeset == NULL || codeset[0] != 0);
   235 	        g_assert (modifier == NULL || modifier[0] != 0);
(lldb)
Comment 1 Rui Matos 2016-01-08 14:06:32 UTC
Created attachment 318494 [details] [review]
gnome-languages: Return early if the locale didn't parse correctly

There's no point in going further if we can't parse the locale and
we can prevent crashes in some corner cases this way.
Comment 2 Rui Matos 2016-01-08 14:10:05 UTC
Review of attachment 318447 [details] [review]:

Thanks, can you re-submit this with the change below ?

I'll also push this other patch to return early in this case. Not checking the return value of gnome_parse_locale() is the real problem here

::: libgnome-desktop/gnome-languages.c
@@ +230,3 @@
         char *name;
 
+        g_assert (language == NULL || language[0] != 0);

language can't be NULL for this function though since its purpose is to get us a normalized locale string and a locale string without language doesn't make sense so, if anything this would need to be changed to

(language != NULL && language[0] != 0)
Comment 3 Koop Mast (kwm) 2016-01-11 10:04:03 UTC
Created attachment 318711 [details] [review]
check if language is !NULL

I took your text as basis for the patch and removed the part that applies to your proposed second patch.
Comment 4 Rui Matos 2016-01-11 13:22:59 UTC
Thanks, all pushed. Note that I edited your patch because the
condition should be && in this case.

   09d331a..cae6091  gnome-3-18 -> gnome-3-18
   a07c8ce..4d9a6eb  master -> master