Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1No1rG-0007Bz-3m for qemu-devel@nongnu.org; Sat, 06 Mar 2010 16:48:26 -0500 Received: from [199.232.76.173] (port=56134 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1No1rF-0007Bd-Pa for qemu-devel@nongnu.org; Sat, 06 Mar 2010 16:48:25 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1No1rE-0008HO-A6 for qemu-devel@nongnu.org; Sat, 06 Mar 2010 16:48:25 -0500 Received: from hall.aurel32.net ([88.191.82.174]:49180) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1No1rE-0008Gu-02 for qemu-devel@nongnu.org; Sat, 06 Mar 2010 16:48:24 -0500 Date: Sat, 6 Mar 2010 22:48:13 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH] json-parser: Fix segfault on malformed input Message-ID: <20100306214813.GJ14275@volta.aurel32.net> References: <1267024678-17225-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1267024678-17225-1-git-send-email-kwolf@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org On Wed, Feb 24, 2010 at 04:17:58PM +0100, Kevin Wolf wrote: > If the parser fails to parse the key in parse_pair, it will access a NULL > pointer. A simple way to trigger this is sending {foo} via QMP. This patch > turns the segfault into a syntax error reply. > > Signed-off-by: Kevin Wolf Thanks, applied. > --- > json-parser.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/json-parser.c b/json-parser.c > index f3debcb..579928f 100644 > --- a/json-parser.c > +++ b/json-parser.c > @@ -264,7 +264,7 @@ static int parse_pair(JSONParserContext *ctxt, QDict *dict, QList **tokens, va_l > > peek = qlist_peek(working); > key = parse_value(ctxt, &working, ap); > - if (qobject_type(key) != QTYPE_QSTRING) { > + if (!key || qobject_type(key) != QTYPE_QSTRING) { > parse_error(ctxt, peek, "key is not a string in object"); > goto out; > } > -- > 1.6.6.1 > > > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net