From patchwork Tue Jun 18 08:05:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 252120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8FC112C02A4 for ; Tue, 18 Jun 2013 18:06:05 +1000 (EST) Received: from localhost ([::1]:58337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoqvS-0004Qw-Np for incoming@patchwork.ozlabs.org; Tue, 18 Jun 2013 04:06:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uoqux-0004Qp-Pl for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:05:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uoqut-0007fa-1e for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:05:31 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:121:10e4::3]:59359) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uoqus-0007ey-PB for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:05:26 -0400 Received: from blackfin.pond.sub.org (p5B32A651.dip0.t-ipconnect.de [91.50.166.81]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 3E150A4617; Tue, 18 Jun 2013 10:05:24 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 75FF7200B4; Tue, 18 Jun 2013 10:05:23 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 18 Jun 2013 10:05:23 +0200 Message-Id: <1371542723-926-1-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.11.7 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:4f8:121:10e4::3 Cc: qemu-trivial@nongnu.org, qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH] acl: acl_add can't insert before last list element, fix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Michael Roth --- 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);