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 ECA5145CC3 for ; Thu, 14 Nov 2024 20:26:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7A3642F5F; Thu, 14 Nov 2024 20:26:32 +0100 (CET) Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) by mails.dpdk.org (Postfix) with ESMTP id 4BC4142F15 for ; Thu, 14 Nov 2024 20:26:25 +0100 (CET) Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3e6005781c0so595760b6e.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=jXN8SmyR60F8YTRwVSCZ1NRYu1roNIdfsSS3KrLsyFk8SZpppSsvEEB9pbKgXON22U GvpBA9aPTUjsat7aiX7gffboteIk4/CSeo2YHpGrOGkBDmlX+RqrLGTK8hu5HGbXszwO 1cZJA+xON7ori8KQSZU6jDtEO1q4cPFiij6F5KbMaE2f+9DXZxFNHpcI7v1AdCcTLoa+ mnqwTH/htO/pdZ8G1PggSUlaD6XqILsP/eOBynNSPcGvlhmnxe3IA6qdnH5Xb8j+dMRU hAOibs6Wy1CSMe3uthpFOmQJUVRus2p+VNK+6Qp+7eyQt7zn7tLyXjJhmU1N04s3BtUn c43A== X-Forwarded-Encrypted: i=1; AJvYcCWjIl/ir/EnsYvlrFhnW4mkJ6wSXWxaQ4Zlbuw1QY7uxz0QGZf2Yh2uJZ/CNew2pVZGB3IYqCM=@dpdk.org X-Gm-Message-State: AOJu0Yw6ub9/6TptJI3yuKCkPAphuPXCgyVDYO484222vrihJ6KEYxRv KTNYn7fmDHU9Xo4/q+QNIlgMzgCujFLGJZIBg4/qE/73blrIjuzMGmbjTYgbjQA= 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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