]> git.ipfire.org Git - thirdparty/qemu.git/commit
acl: acl_add can't insert before last list element, fix
authorMarkus Armbruster <armbru@redhat.com>
Tue, 18 Jun 2013 08:05:23 +0000 (10:05 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 12 Aug 2013 20:14:38 +0000 (15:14 -0500)
commit820508eea686e47c4be880a7752c6b7b8f74e425
tree7b07f0e09a64d61025cb166dee071d2aa7057182
parent1e3043a702caea8ab6ffbfff6e273d6a3f88c1e7
acl: acl_add can't insert before last list element, fix

Watch this:

    $ upstream-qemu -nodefaults -S -vnc :0,acl,sasl -monitor stdio
    QEMU 1.5.50 monitor - type 'help' for more information
    (qemu) acl_add vnc.username drei allow
    acl: added rule at position 1
    (qemu) acl_show vnc.username
    policy: deny
    1: allow drei
    (qemu) acl_add vnc.username zwei allow 1
    acl: added rule at position 2
    (qemu) acl_show vnc.username
    policy: deny
    1: allow drei
    2: allow zwei
    (qemu) acl_add vnc.username eins allow 1
    acl: added rule at position 1
    (qemu) acl_show vnc.username
    policy: deny
    1: allow eins
    2: allow drei
    3: allow zwei

The second acl_add inserts at position 2 instead of 1.

Root cause is an off-by-one in qemu_acl_insert(): when index ==
acl->nentries, it appends instead of inserting before the last list
element.

Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit 4999f3a8a6009de05ba82e58e723277917f16254)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
util/acl.c