From 83093dfcfe48593331e44667aaa687b153cbc802 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 15 Jan 2020 15:45:21 +0200 Subject: [PATCH] acl: Improve attribute rights check error handling --- src/plugins/acl/acl-mailbox.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) 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; } -- 2.47.3