From: Timo Sirainen Date: Wed, 15 Jan 2020 13:45:21 +0000 (+0200) Subject: acl: Improve attribute rights check error handling X-Git-Tag: 2.3.10~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=83093dfcfe48593331e44667aaa687b153cbc802;p=thirdparty%2Fdovecot%2Fcore.git acl: Improve attribute rights check error handling --- diff --git a/src/plugins/acl/acl-mailbox.c b/src/plugins/acl/acl-mailbox.c index fabaa06410..0d3774876a 100644 --- a/src/plugins/acl/acl-mailbox.c +++ b/src/plugins/acl/acl-mailbox.c @@ -496,16 +496,22 @@ bool acl_mailbox_have_extra_attribute_rights(struct mailbox *box) they have the "l" right and any one of the "r", "s", "w", "i", or "p" rights. */ - if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_READ) > 0) - return TRUE; - if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_SEEN) > 0) - return TRUE; - if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0) - return TRUE; - if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_INSERT) > 0) - return TRUE; - if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_POST) > 0) - return TRUE; + const enum acl_storage_rights check_rights[] = { + ACL_STORAGE_RIGHT_READ, + ACL_STORAGE_RIGHT_WRITE_SEEN, + ACL_STORAGE_RIGHT_WRITE, + ACL_STORAGE_RIGHT_INSERT, + ACL_STORAGE_RIGHT_POST, + }; + for (unsigned int i = 0; i < N_ELEMENTS(check_rights); i++) { + int ret = acl_mailbox_right_lookup(box, check_rights[i]); + if (ret > 0) + return TRUE; + if (ret < 0) { + /* unexpected error - stop checking further */ + return FALSE; + } + } return FALSE; }