qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Qemu-stable] [PATCH] acl: acl_add can't insert before


From: mdroth
Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH] acl: acl_add can't insert before last list element, fix
Date: Tue, 18 Jun 2013 13:15:12 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Jun 18, 2013 at 10:05:23AM +0200, Markus Armbruster wrote:
> 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: address@hidden
> Signed-off-by: Markus Armbruster <address@hidden>

Reviewed-by: Michael Roth <address@hidden>

> ---
>  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
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]