Bug 3009 - "Rebuild folder tree" causes SIGSEGV if a directory name isn't valid utf-8
Summary: "Rebuild folder tree" causes SIGSEGV if a directory name isn't valid utf-8
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: Folders (show other bugs)
Version: 3.9.2
Hardware: PC FreeBSD
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2013-10-06 16:50 UTC by Fabian Keil
Modified: 2013-12-28 17:37 UTC (History)
0 users

See Also:


Attachments
Let folder_item_new() convert the filename to utf8, to prevent crashes later on (939 bytes, patch)
2013-10-06 16:50 UTC, Fabian Keil
no flags Details | Diff

Description Fabian Keil 2013-10-06 16:50:54 UTC
Created attachment 1299 [details]
Let folder_item_new() convert the filename to utf8, to prevent crashes later on

If the mailbox contains a directory whose name isn't valid utf-8, "Rebuild folder tree" causes a segmentation fault:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 80a806400 (LWP 100502)]
strcoll_l (s=<optimized out>, s2=<optimized out>, locale=<optimized out>) at /usr/src/lib/libc/string/strcoll.c:65
65		while(*t && *t2) {
(gdb) where
#0  strcoll_l (s=<optimized out>, s2=<optimized out>, locale=<optimized out>) at /usr/src/lib/libc/string/strcoll.c:65
#1  0x000000080919e84b in strcoll (s=0x0, s2=0x80bc565a8 "[...]") at /usr/src/lib/libc/string/strcoll.c:100
#2  0x000000080634af4a in g_utf8_collate (str1=0x80bc55fd8 "[...]\374[...]", str2=0x80bc50438 "[...]") at gunicollate.c:136
#3  0x00000000004b9070 in folderview_clist_compare (clist=0x80a9543f0, ptr1=0x80ab4fc30, ptr2=0x80ab4f930) at folderview.c:2574
#4  0x0000000000691f34 in sink (clist=0x80a9543f0, numbers=0x80bd20160, root=3, bottom=7) at gtksctree.c:1082
#5  0x0000000000691dd9 in heap_sort (clist=0x80a9543f0, numbers=0x80bd20160, array_size=7) at gtksctree.c:1103
#6  0x000000000068f681 in stree_sort (ctree=0x80a9543f0, node=0x80bc69180, data=0x0) at gtksctree.c:1145
#7  0x000000000066204f in gtk_cmctree_post_recursive (ctree=0x80a9543f0, node=0x80bc69180, func=0x68f540 <stree_sort>, data=0x0) at gtkcmctree.c:3334
#8  0x0000000000662022 in gtk_cmctree_post_recursive (ctree=0x80a9543f0, node=0x80bc690c0, func=0x68f540 <stree_sort>, data=0x0) at gtkcmctree.c:3329
#9  0x000000000068f49e in gtk_sctree_sort_recursive (ctree=0x80a9543f0, node=0x80bc690c0) at gtksctree.c:1205
[...]

The attached patch is one way to address the problem.
Comment 1 Ricardo Mones 2013-10-06 20:14:40 UTC
I've not tested the patch, but, while it's desirable that folders created by Claws Mail doesn't trigger this crash, the problem will reappear with folders created externally by other means. So better have a patch for that case too :)
Comment 2 Fabian Keil 2013-10-07 11:05:45 UTC
folder_item_new() is called for each already-existing directory in the mailbox directory.

As far as "Rebuild folder tree" is concerned it shouldn't matter how the directory was created.
Comment 3 users 2013-12-05 11:03:08 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=14d1a1ad3e4e4b4cf3601eba1b31d405bda1c9ec
Merge: 6c07c87 dc2158a
Author: Colin Leroy <colin@colino.net>
Date:   Thu Dec 5 11:03:05 2013 +0100

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=dc2158a308abd87c9ca243e9097d2e202e8514cb
Author: Ricardo Mones <ricardo@mones.org>
Date:   Thu Dec 5 11:00:29 2013 +0100

    Fix bug #3009 ‘"Rebuild folder tree" causes SIGSEGV if a directory name isn't valid utf-8’
    
    Based on initial patch submitted by Fabian Keil <fk@fabiankeil.de>
Comment 4 users 2013-12-05 12:04:04 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=097e4411caeccbcc5a0a3df713bac6a6461770a0
Merge: 14d1a1a 76d08bc
Author: Colin Leroy <colin@colino.net>
Date:   Thu Dec 5 12:04:03 2013 +0100

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=76d08bcbc5cce95e3e546cc718b71e4e972035e0
Author: Colin Leroy <colin@colino.net>
Date:   Thu Dec 5 12:05:24 2013 +0100

    Better fix for bug #3009; conv_filename_to_utf8() converts strings
    in local filename encoding to UTF-8 even if local filename encoding
    is UTF-8, leading to double UTF-8 encoding.

Note You need to log in before you can comment on or make changes to this bug.