[Dovecot] bug uni_utf8_str_is_valid(vname)

Jernej Porenta
2012-03-06T13:28:50Z

Heya,

We are expiriencing issues with dovecot 2.1.1 on Linux with weird filenames in
home directory of username. We are using mbox IMAP folders, with no special
changes (mail_location = mbox:~/:INBOX=%h/.mailbox).

Mar  6 13:37:17 machine dovecot: imap(username): Panic: file mail-storage.c:
line 628 (mailbox_alloc): assertion failed: (uni_utf8_str_is_valid(vname))
Mar  6 13:37:17 machine dovecot: imap(username): Error: Raw backtrace:
/opt/dovecot-2.1.1/lib/dovecot/libdovecot.so.0 [0x2ba41cb79450] ->
/opt/dovecot-2.1.1/lib/dovecot/libdovecot.so.0 [0x2ba41cb794a6] ->
/opt/dovecot-2.1.1/lib/dovecot/libdovecot.so.0 [0x2ba41cb78963] ->
/opt/dovecot-2.1.1/lib/dovecot/libdovecot-storage.so.0 [0x2ba41c87ebd5] ->
/opt/dovecot-2.1.1/lib/dovecot/libdovecot-storage.so.0 [0x2ba41c88c12c] ->
/opt/dovecot-2.1.1/lib/dovecot/libdovecot-storage.so.0(fs_list_iter_next+0x1b4)
[0x2ba41c88c494] -> /opt/dovecot-2.1.1/lib/dovecot/libdovecot-storage.so.0
[0x2ba41c885342] ->
/opt/dovecot-2.1.1/lib/dovecot/libdovecot-storage.so.0(mailbox_list_iter_next+0x234)
[0x2ba41c885604] -> dovecot/imap [0x40b2d1] ->
dovecot/imap(cmd_list_full+0x520) [0x40c1f0] -> dovecot/imap(cmd_list+0xb)
[0x40c3eb] -> dovecot/imap(command_exec+0x37) [0x410427] -> dovecot/imap
[0x40f4cd] -> dovecot/imap [0x40f582] ->
dovecot/imap(client_handle_input+0x3f) [0x40f6cf] ->
dovecot/imap(client_input+0x62) [0x410052] -> /opt/dovecot
Mar  6 13:37:17 machine dovecot: imap(username): Fatal: master: service(imap):
child 20873 killed with signal 6 (core dumps disabled)

The bug is reproducible by using home folder structure available from:
http://bit.ly/x8pTXS

AFAIK, the problem lies in processing the file list of home folder, which can
contain filenames that do not have proper UTF-8 encoding of filenames, which
causes dovecot to crash. On the other hand, UTF-8 filenames created on the
system by hand (using touch), are not displayed in IMAP LIST command (sample is
included in the folder structure; single letter file).

Cheers, Jernej