aboutsummaryrefslogtreecommitdiff
path: root/util/acl.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2013-06-18 10:05:23 +0200
committerMichael Tokarev <mjt@tls.msk.ru>2013-06-21 22:52:50 +0400
commit4999f3a8a6009de05ba82e58e723277917f16254 (patch)
tree9f263bde269276eb75f6ce83a83e163b754c6bdf /util/acl.c
parentf2c4ddd9c32f7f389e83a0d866fb600e37985d03 (diff)
downloadqemu-4999f3a8a6009de05ba82e58e723277917f16254.zip
qemu-4999f3a8a6009de05ba82e58e723277917f16254.tar.gz
qemu-4999f3a8a6009de05ba82e58e723277917f16254.tar.bz2
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>
Diffstat (limited to 'util/acl.c')
-rw-r--r--util/acl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/acl.c b/util/acl.c
index a7f33ff..938b7ae 100644
--- a/util/acl.c
+++ b/util/acl.c
@@ -138,9 +138,9 @@ int qemu_acl_insert(qemu_acl *acl,
if (index <= 0)
return -1;
- if (index >= acl->nentries)
+ if (index > acl->nentries) {
return qemu_acl_append(acl, deny, match);
-
+ }
entry = g_malloc(sizeof(*entry));
entry->match = g_strdup(match);