From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, qemu-stable@nongnu.org
Subject: [Qemu-devel] [PATCH] acl: acl_add can't insert before last list element, fix
Date: Tue, 18 Jun 2013 10:05:23 +0200 [thread overview]
Message-ID: <1371542723-926-1-git-send-email-armbru@redhat.com> (raw)
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>
---
util/acl.c | 4 ++--
1 file 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);
--
1.7.11.7
next reply other threads:[~2013-06-18 8:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 8:05 Markus Armbruster [this message]
2013-06-18 18:15 ` [Qemu-devel] [Qemu-stable] [PATCH] acl: acl_add can't insert before last list element, fix mdroth
2013-06-19 7:44 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-07-31 14:44 ` [Qemu-devel] " Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371542723-926-1-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).