From patchwork Tue Aug 13 15:10:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 266880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (unknown [IPv6:2001:4830:134:3::12]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B6E382C014B for ; Wed, 14 Aug 2013 02:12:19 +1000 (EST) Received: from localhost ([::1]:36758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9GLX-00021o-PW for incoming@patchwork.ozlabs.org; Tue, 13 Aug 2013 11:17:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9GGH-0004UG-7a for qemu-devel@nongnu.org; Tue, 13 Aug 2013 11:11:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9GGC-0003iK-CK for qemu-devel@nongnu.org; Tue, 13 Aug 2013 11:11:53 -0400 Received: from mail-ob0-x22a.google.com ([2607:f8b0:4003:c01::22a]:56912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9GGB-0003i5-VH; Tue, 13 Aug 2013 11:11:48 -0400 Received: by mail-ob0-f170.google.com with SMTP id eh20so8771601obb.15 for ; Tue, 13 Aug 2013 08:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=JFFMY7psPTkNkBVU3Q0o+zekdeCI2JtWoPPu39v/c/U=; b=Rk2Kir8ePUdJe68y7BVMUUYddBnW15TH0X5V+soiKZUTRIRie8jE9z4MNh90VMGiGl 2DWxCdYIu+s4Iz2koFugzUY+behEVqSwUBBpRPe59ptZpeupfR0gSA9y4olfMqL51/GQ ANLPOzFY9mvoeWNVOG/oU6XntUkzPyxecCZlS5jmgX5L7+bA8si1LmpIL6gywTafsill l7oN+cMI9D+JjafILnl/noR0lDpacbcGeA/Yw47UQzroGeZpe8D2JZ73meaw2WN7u92l +Ob/ehbuVg18oB7A8GO1RqpcaOr0ULEG8k7VZo4+8OLRVaFwrFUC6dMSM7mnD9ghUHPJ JJkg== X-Received: by 10.182.142.104 with SMTP id rv8mr16237646obb.3.1376406707414; Tue, 13 Aug 2013 08:11:47 -0700 (PDT) Received: from loki.austin.ibm.com ([32.97.110.51]) by mx.google.com with ESMTPSA id uz16sm12947878obc.5.2013.08.13.08.11.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Aug 2013 08:11:46 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 13 Aug 2013 10:10:30 -0500 Message-Id: <1376406680-16302-7-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1376406680-16302-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1376406680-16302-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::22a Cc: aliguori@us.ibm.com, qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 06/56] 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 From: Markus Armbruster 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 Signed-off-by: Michael Tokarev (cherry picked from commit 4999f3a8a6009de05ba82e58e723277917f16254) Signed-off-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);