From nobody Thu May 2 22:29:14 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553787672694373.9749767165848; Thu, 28 Mar 2019 08:41:12 -0700 (PDT) Received: from localhost ([127.0.0.1]:38143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9X9R-0002GO-6e for importer@patchew.org; Thu, 28 Mar 2019 11:41:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9X5O-0007n6-1u for qemu-devel@nongnu.org; Thu, 28 Mar 2019 11:36:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9WvP-0004SR-M0 for qemu-devel@nongnu.org; Thu, 28 Mar 2019 11:26:43 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33516) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h9WvP-0004SD-CS for qemu-devel@nongnu.org; Thu, 28 Mar 2019 11:26:39 -0400 Received: by mail-wr1-x441.google.com with SMTP id q1so23452041wrp.0 for ; Thu, 28 Mar 2019 08:26:39 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id g8sm53236816wro.77.2019.03.28.08.26.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2019 08:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kInSicJR/vVsW6djbl9cgFCEDPfeMwx48sh0HIt9rxs=; b=ghUmdtUirOGunlH3dunjD3ccu8kBQllYjYmTZnctI2KiCAb2NyUhKsH4ZBlff9BnyD AOgDroC1pZpEjBgBA8HOcOlhdTY321WZEZm4Sxj2Ms+PU8K3GrsDHY1Jw+d5SpSaHjIM wGORG6ZKzdfzaAtUVwrDl7Lz7+0Gu4aO4l4k7Ofx8n2FRyn0gRTd9J9F0aMRERFzVuKU +D0nVy/6792etTylZXb/A5JIXI1B/dKmKo5aGoQ4M4uA3fawojyNXMCtQMBUaAPyvUcC 5WRxfcfn5Op3me7FDS9csusHCDd45gTFTv7VbjijGUG8WJwdgfcezQGNXuBsyb3hcl0j u5/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kInSicJR/vVsW6djbl9cgFCEDPfeMwx48sh0HIt9rxs=; b=Yb6IB4Xdzum1s08u8ueYm/myiOp24bqN9twJZ1jKntWlZ1pMODlumx60Si8h48wOB1 sXzqvjMNUsOdI0qRDRJ0utpSNX2nKRlSaBHa80hlfNV4fPo8HdQi1PGWcMEAxc3v7QBV 4KWNbTrWXu56lNMM/WdySYrdyy3forFNV/baq5gEWFi+pguUd0qf/EdsWZ3xQcBaezvR 5o/FxUB4lY5MDvwzWK81bXpIgpGbOBSBSuMr8Vy1L3Y4Pe2zlml1296qn7nvi8sWrGWF DoMt48XaZkQwU/BpN37K2NTQ97c6V8rYdzRLZxAjJo6YvEFvPYP5iAo7fw8xygew++nA CDJg== X-Gm-Message-State: APjAAAVPFOdkcCPoi/gLw+VZfvmB/rNogo6Zo/swk54uq487oTTbP17Z 5fFUGR4k+wnNuzKLgBNxfKOkfA== X-Google-Smtp-Source: APXvYqxpLYznUd7oX9ffRYktnHX652EoL2nXF5KJlql7vmzs1vOe5AGzXNdR7yq7qiFYGjFnRkAWoQ== X-Received: by 2002:adf:ebc8:: with SMTP id v8mr27659065wrn.172.1553786798152; Thu, 28 Mar 2019 08:26:38 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Thu, 28 Mar 2019 15:26:35 +0000 Message-Id: <20190328152635.2794-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH for-4.1] hw/ssi/xilinx_spips: Avoid variable length array 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: , Cc: "Edgar E . Iglesias" , Alistair Francis , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In the stripe8() function we use a variable length array; however we know that the maximum length required is MAX_NUM_BUSSES. Use a fixed-length array and an assert instead. Signed-off-by: Peter Maydell Reviewed-by: Alistair Francis Reviewed-by: Francisco Iglesias Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella --- hw/ssi/xilinx_spips.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c index 16f88f74029..c615058cc1b 100644 --- a/hw/ssi/xilinx_spips.c +++ b/hw/ssi/xilinx_spips.c @@ -429,12 +429,14 @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d) =20 static inline void stripe8(uint8_t *x, int num, bool dir) { - uint8_t r[num]; - memset(r, 0, sizeof(uint8_t) * num); + uint8_t r[MAX_NUM_BUSSES]; int idx[2] =3D {0, 0}; int bit[2] =3D {0, 7}; int d =3D dir; =20 + assert(num <=3D MAX_NUM_BUSSES); + memset(r, 0, sizeof(uint8_t) * num); + for (idx[0] =3D 0; idx[0] < num; ++idx[0]) { for (bit[0] =3D 7; bit[0] >=3D 0; bit[0]--) { r[idx[!d]] |=3D x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0; --=20 2.20.1