]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
acl: Improve attribute rights check error handling
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Jan 2020 13:45:21 +0000 (15:45 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 23 Jan 2020 12:36:05 +0000 (12:36 +0000)
src/plugins/acl/acl-mailbox.c

index fabaa06410825a954ad0b4008b76b2689adbe0e0..0d3774876a921aea6c132a4c9e43fdb242d644a5 100644 (file)
@@ -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;
 }