From patchwork Thu Mar 21 11:57:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10863397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A337D922 for ; Thu, 21 Mar 2019 12:05:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 897D728C2E for ; Thu, 21 Mar 2019 12:05:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D95328C8A; Thu, 21 Mar 2019 12:05:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 332892A00B for ; Thu, 21 Mar 2019 12:05:31 +0000 (UTC) Received: from localhost ([127.0.0.1]:36168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6wRt-0000py-KE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Mar 2019 08:05:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6wQj-0007vp-Qc for qemu-devel@nongnu.org; Thu, 21 Mar 2019 08:04:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6wKo-0004yU-Bm for qemu-devel@nongnu.org; Thu, 21 Mar 2019 07:58:12 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6wKk-0004pt-Io for qemu-devel@nongnu.org; Thu, 21 Mar 2019 07:58:08 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2LBsc0x050499; Thu, 21 Mar 2019 11:58:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=ML0UVdRIvQ7FHYek7wVb7aqdzKnR+oDYqCdL5RzHxsY=; b=n7DrWu9+iV4g1P1a0wojJGlQh0xRyEQLyqe295VjoL0VFHD8KFXpG7lwKPi29Gm0jE/L 8c4SIUgfkzGFkfU7e/z++ZFZ0e4tjFOxg4hKQ8WJ8l4tWVl2wKut+hMYLl+GiTZuDo8M 37/ux199lWL8rBlQb3tRXevb/HhMaqS+7aoGkS6jo5C4/lVBQuQCxAYikZBJs1CAvAlM Umh9R3jb3+FFCIkuYpuBAuwm08rjJHO9g/1oapGlTFURBJ/mxWa1rsLmUgPsaZ+OnptZ 2qywa3zRTWYDLPkGPQRuKm3Lza6EgZgVfrN2cyQg6hyDx5GZZZ2yV+bWXOcFzXnsQ67n zQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2r8rjv00rq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Mar 2019 11:58:01 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2LBw0x2011049 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Mar 2019 11:58:01 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2LBw01D003398; Thu, 21 Mar 2019 11:58:00 GMT Received: from ol7.nl.oracle.com (/10.175.16.58) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Mar 2019 04:58:00 -0700 From: Liam Merwick To: armbru@redhat.com, qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 11:57:52 +0000 Message-Id: <1553169472-25325-1-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9201 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=775 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903210088 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH] json: Fix off-by-one assert check in next_state() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The assert checking if the value of lexer->state in next_state(), which is used as an index to the 'json_lexer' array, incorrectly checks for an index value less than or equal to ARRAY_SIZE(json_lexer). Fix assert so that it just checks for an index less than the array size. Signed-off-by: Liam Merwick Reviewed-by: Li Qiang Reviewed-by: Markus Armbruster Reviewed-by: Stefano Garzarella --- qobject/json-lexer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c index a7df2093aa30..632320d72d5d 100644 --- a/qobject/json-lexer.c +++ b/qobject/json-lexer.c @@ -266,7 +266,7 @@ static inline uint8_t next_state(JSONLexer *lexer, char ch, bool flush, { uint8_t next; - assert(lexer->state <= ARRAY_SIZE(json_lexer)); + assert(lexer->state < ARRAY_SIZE(json_lexer)); next = json_lexer[lexer->state][(uint8_t)ch]; *char_consumed = !flush && !(next & LOOKAHEAD); return next & ~LOOKAHEAD;