From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C209345CC3; Thu, 14 Nov 2024 20:27:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8000F42F4D; Thu, 14 Nov 2024 20:26:31 +0100 (CET) Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by mails.dpdk.org (Postfix) with ESMTP id 4C4F242F19 for ; Thu, 14 Nov 2024 20:26:25 +0100 (CET) Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3e6005781c0so595761b6e.3 for ; Thu, 14 Nov 2024 11:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731612384; x=1732217184; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5JZORmd2j6FMqamoaGDtnn3byz//SEEn0uKe0BmJwH8=; b=iu9RCA9L9pAfyBHEfGFvEUSdMt58RoItT4Kz3vRWo28WrT5P0a1uctFOCgn+XK+o+3 zBIUgElwMY2DNTRhwhvQnmUNmlqiehqjANWBNeWkDsINAItmnXHbX4FdWL/+AmRLp4Ep GhsvHVpvlFLOsmtg1+3gUi5A2HFtfaR5wcNTRXv2taJyvSaUFtR6bOljcXtHB3mWI0Dm 7fsfWgQPVqtGJzaNUInGvmby11G/mhltWitY9jqe26x9FxFOWTC8G2aFiGSjUVP4YPJt alJtAumoW79vOJQ70/KHfErop0yn+On2YjVZtzQpeRpupLHBsJIAz0SSpGlUtqR5GMKy QgLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731612384; x=1732217184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5JZORmd2j6FMqamoaGDtnn3byz//SEEn0uKe0BmJwH8=; b=B8g7zlKvVkIRnUiM3w5Xu3nFuO4CTPfm7nwQ3cs9OIeeRAi8TmAVudlWBHc0hHGIyI YdZGaX7xtGBK+kNHGcj2BjDaxdHigsXL1JEEuaLR3Qks1JEa40GC1SKZJnoIZz2Nw5VK h+Y4CqQVrPSaQDitVi103gZoKyxIdALYQ3Fut0qDikGMYDZomcuCIlq1oKIKbd0yUdC1 Ip6tmx8EMdZtRSVZS0Ivj5yynzzrm4fmCOVCh5vjVCjvsgbBFof5Ilnnk0+Mhx+Wyp7a 58xngp/xV5xQ9/TxOQmlAK8LulFGMF+/HiSXeU96lc/vKU31FAG+raH8TAyhmXPahR/M +95A== X-Gm-Message-State: AOJu0YzL1cvxGUgsjnSoVbOOGkNA5vv5mDXWERC4E8g0oX9Qsrk8UJmF kRvnGGhNZp5Yx8+sfPtqPujvLXjKJz4zZowOkgHPe4DwLGbJrxWu8XUv4whKrrO/vx3mwUe7isV +fRk= X-Google-Smtp-Source: AGHT+IFNx2Pvh9D5L/z/zmNtIs2sGcCSGkOHiwqrg7UWyLxJOTaZI39j+HLHMegl76JVoZbQp/UnJQ== X-Received: by 2002:a05:6808:1203:b0:3e6:5892:309a with SMTP id 5614622812f47-3e7bc84e865mr101004b6e.30.1731612384545; Thu, 14 Nov 2024 11:26:24 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7f8b37f3466sm1461632a12.35.2024.11.14.11.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 11:26:23 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , getelson@nvidia.com, stable@dpdk.org, Ori Kam , Aman Singh Subject: [PATCH v2 09/10] app/test-pmd: avoid potential outside of array reference Date: Thu, 14 Nov 2024 11:25:07 -0800 Message-ID: <20241114192603.41145-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114192603.41145-1-stephen@networkplumber.org> References: <20241114001403.147609-1-stephen@networkplumber.org> <20241114192603.41145-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The order of comparison is wrong, and potentially allows referencing past the array. Link: https://pvs-studio.com/en/blog/posts/cpp/1179/ Fixes: 3e3edab530a1 ("ethdev: add flow quota") Cc: getelson@nvidia.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- app/test-pmd/cmdline_flow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 1e4f2ebc55..9e4fc2d95d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -12892,7 +12892,7 @@ comp_names_to_index(struct context *ctx, const struct token *token, RTE_SET_USED(token); if (!buf) return names_size; - if (names[ent] && ent < names_size) + if (ent < names_size && names[ent] != NULL) return rte_strscpy(buf, names[ent], size); return -1; -- 2.45.2