From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKRul-0007Hg-RR for qemu-devel@nongnu.org; Fri, 13 Sep 2013 07:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKRuf-0001ZD-PP for qemu-devel@nongnu.org; Fri, 13 Sep 2013 07:51:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKRuf-0001Z1-Hv for qemu-devel@nongnu.org; Fri, 13 Sep 2013 07:51:49 -0400 From: Kevin Wolf Date: Fri, 13 Sep 2013 13:51:02 +0200 Message-Id: <1379073063-14963-33-git-send-email-kwolf@redhat.com> In-Reply-To: <1379073063-14963-1-git-send-email-kwolf@redhat.com> References: <1379073063-14963-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 32/33] block: Assert validity of BdrvActionOps List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Max Reitz In qmp_transaction, assert that the BdrvActionOps to be used is actually valid. This assertion failing is very improbable, however, it might happen, if a new TransactionActionKind is introduced "out of order" and the actions[] array is not updated. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- blockdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/blockdev.c b/blockdev.c index 2ab236a..80605a2 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1286,6 +1286,8 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp) assert(dev_info->kind < ARRAY_SIZE(actions)); ops = &actions[dev_info->kind]; + assert(ops->instance_size > 0); + state = g_malloc0(ops->instance_size); state->ops = ops; state->action = dev_info; -- 1.8.1.4