From nobody Fri May 17 18:18:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553169966895833.576449624406; Thu, 21 Mar 2019 05:06:06 -0700 (PDT) Received: from localhost ([127.0.0.1]:36168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6wSM-0000py-BO for importer@patchew.org; Thu, 21 Mar 2019 08:05:58 -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 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 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== 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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; =20 - assert(lexer->state <=3D ARRAY_SIZE(json_lexer)); + assert(lexer->state < ARRAY_SIZE(json_lexer)); next =3D json_lexer[lexer->state][(uint8_t)ch]; *char_consumed =3D !flush && !(next & LOOKAHEAD); return next & ~LOOKAHEAD; --=20 1.8.3.1