[Dovecot] namespaces and creation of folders that contain folders...

bhayden at umn.edu bhayden at umn.edu
Tue Aug 14 05:58:52 EEST 2007


Hi Timo and all. imap/cmd-create.c contains the following bit of code:

        len = strlen(full_mailbox);
        if (len == 0 || full_mailbox[len-1] != ns->sep)
                directory = FALSE;
        else {
                /* name ends with hierarchy separator - client is just
                   informing us that it wants to create children under this
                   mailbox. */
                directory = TRUE;
                mailbox = t_strndup(mailbox, len-1);
                full_mailbox = t_strndup(full_mailbox, 
strlen(full_mailbox)-1);
        i_info("Z CREATE NAME: YYY%sYYY", mailbox);
        }

We've been having trouble with people not being able to create a mail 
folder that will contain other folders. Tried it both with users using mbox 
(where this would be a filesystem directory) and maildir. Failed everytime 
because of a test which rejects folder names that end with MAILDIR_FS_SEP.

Looks like the above bit of code is supposed to catch these, make a note of 
the fact that the client wants a directory, and strip off that trailing 
separator. In fact, it does this in the case of 'full_mailbox'. However, 
for 'mailbox' (it seems to me) the code is incorrect as its using the len-1 
which is the length of 'full_mailbox', not 'mailbox'. This means that when 
'mailbox' and 'full_mailbox' are the same length--that is, for the default 
namespace (no prefix), it happens to work. However, in any other namespace, 
it won't, as 'full_mailbox' will always be longer then 'mailbox' if there 
is a ns prefix, and hence that trailing separator won't be trimmed. (As a 
matter of fact, in the unlikely instance that the prefix is a single 
character this will trim the null character from 'mailbox', which probably 
isn't a good thing.)

So. Am I missing something, or crazy, or is this really a bug? Thanks,

-Brian


More information about the dovecot mailing list