Mercurial > dovecot > core-2.2
changeset 3984:882ec6cc5970 HEAD
Limit maximum mailbox name length while creating them.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 05 Feb 2006 15:03:40 +0200 |
parents | 565e3040a9f5 |
children | 38c352bb7bb7 |
files | src/lib-storage/index/dbox/dbox-storage.c src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/mbox/mbox-storage.c |
diffstat | 3 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox/dbox-storage.c Sun Feb 05 14:59:01 2006 +0200 +++ b/src/lib-storage/index/dbox/dbox-storage.c Sun Feb 05 15:03:40 2006 +0200 @@ -18,6 +18,10 @@ #define CREATE_MODE 0770 /* umask() should limit it more */ +/* Don't allow creating too long mailbox names. They could start causing + problems when they reach the limit. */ +#define DBOX_MAX_MAILBOX_NAME_LENGTH (PATH_MAX/2) + struct rename_context { bool found; size_t oldnamelen; @@ -178,7 +182,8 @@ len = strlen(name); if (name[0] == '\0' || name[len-1] == '/' || - strchr(name, '*') != NULL || strchr(name, '%') != NULL) + strchr(name, '*') != NULL || strchr(name, '%') != NULL || + len > DBOX_MAX_MAILBOX_NAME_LENGTH) return FALSE; return dbox_is_valid_mask(storage, name);
--- a/src/lib-storage/index/maildir/maildir-storage.c Sun Feb 05 14:59:01 2006 +0200 +++ b/src/lib-storage/index/maildir/maildir-storage.c Sun Feb 05 15:03:40 2006 +0200 @@ -18,6 +18,10 @@ #define CREATE_MODE 0770 /* umask() should limit it more */ +/* Don't allow creating too long mailbox names. They could start causing + problems when they reach the limit. */ +#define MAILDIR_MAX_MAILBOX_NAME_LENGTH (PATH_MAX/2) + struct rename_context { bool found; size_t oldnamelen; @@ -179,8 +183,8 @@ size_t len; len = strlen(name); - if (len == 0 || name[0] == MAILDIR_FS_SEP || - name[len-1] == MAILDIR_FS_SEP || + if (len == 0 || len > MAILDIR_MAX_MAILBOX_NAME_LENGTH || + name[0] == MAILDIR_FS_SEP || name[len-1] == MAILDIR_FS_SEP || strchr(name, '*') != NULL || strchr(name, '%') != NULL) return FALSE;
--- a/src/lib-storage/index/mbox/mbox-storage.c Sun Feb 05 14:59:01 2006 +0200 +++ b/src/lib-storage/index/mbox/mbox-storage.c Sun Feb 05 15:03:40 2006 +0200 @@ -22,6 +22,10 @@ #define CREATE_MODE 0770 /* umask() should limit it more */ +/* Don't allow creating too long mailbox names. They could start causing + problems when they reach the limit. */ +#define MBOX_MAX_MAILBOX_NAME_LENGTH (PATH_MAX/2) + /* NOTE: must be sorted for istream-header-filter. Note that it's not such a good idea to change this list, as the messages will then change from client's point of view. So if you do it, change all mailboxes' UIDVALIDITY @@ -384,7 +388,8 @@ len = strlen(name); if (name[0] == '\0' || name[len-1] == '/' || - strchr(name, '*') != NULL || strchr(name, '%') != NULL) + strchr(name, '*') != NULL || strchr(name, '%') != NULL || + len > MBOX_MAX_MAILBOX_NAME_LENGTH) return FALSE; return mbox_is_valid_mask(storage, name);