]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
acl: Fix return value of acl_attribute_get_acl
authorAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 24 May 2018 12:48:58 +0000 (12:48 +0000)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 30 Jul 2018 07:29:46 +0000 (10:29 +0300)
If matching acl entry is not found, it must return 0
and not 1 because it did not find anything.

Fixes dsync: Panic: file mailbox-attribute.c: line 362 (mailbox_attribute_get_stream): assertion failed: (value_r->value != NULL || value_r->value_stream != NULL)

Broken in 37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3a

Found by @dl8bh

src/plugins/acl/acl-attributes.c

index 2499a30f9c1131f631d5ac7a89680105d782e25b..f0d3177de49fca4b0a020b4aaeff3b91a01c8dcf 100644 (file)
@@ -60,7 +60,7 @@ static int acl_attribute_get_acl(struct mailbox *box, const char *key,
        struct acl_object_list_iter *iter;
        struct acl_rights rights, wanted_rights;
        const char *id;
-       int ret;
+       int ret = 0;
 
        i_zero(value_r);
 
@@ -88,11 +88,17 @@ static int acl_attribute_get_acl(struct mailbox *box, const char *key,
                    rights.id_type == wanted_rights.id_type &&
                    null_strcmp(rights.identifier, wanted_rights.identifier) == 0) {
                        value_r->value = acl_rights_export(&rights);
+                       ret = 1;
                        break;
                }
        }
-       if ((ret = acl_object_list_deinit(&iter)) < 0)
+       /* the return value here cannot be used, because this function
+          needs to return whether it actually matched something
+          or not */
+       if (acl_object_list_deinit(&iter) < 0) {
                mail_storage_set_internal_error(box->storage);
+               ret = -1;
+       }
        return ret;
 }