From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ0LX-0002e4-Ae for qemu-devel@nongnu.org; Mon, 14 Nov 2011 12:29:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQ0LW-0008Gl-69 for qemu-devel@nongnu.org; Mon, 14 Nov 2011 12:29:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ0LV-0008GL-UK for qemu-devel@nongnu.org; Mon, 14 Nov 2011 12:29:26 -0500 Date: Mon, 14 Nov 2011 15:29:20 -0200 From: Luiz Capitulino Message-ID: <20111114152920.37edca6f@doriath> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 1.0?] qapi: Check for negative enum values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: mdroth@linux.vnet.ibm.com We don't currently check for negative enum values in qmp_output_type_enum(), this will very likely generate a segfault when triggered. However, it _seems_ that no code in tree can trigger this today. Signed-off-by: Luiz Capitulino --- I think it's a good idea to merge this one for 1.0, but I'd be ok to queue it for 1.1 in case we're only merging fixes for "real" bugs. I found this while extending the QAPI's unit-tests... qapi/qmp-output-visitor.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index d67724e..f76d015 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -190,7 +190,7 @@ static void qmp_output_type_enum(Visitor *v, int *obj, const char *strings[], assert(strings); while (strings[i++] != NULL); - if (value >= i - 1) { + if (value < 0 || value >= i - 1) { error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null"); return; } -- 1.7.8.rc2.dirty