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 8E28745D16 for ; Fri, 15 Nov 2024 21:08:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1B70432EC; Fri, 15 Nov 2024 21:08:16 +0100 (CET) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by mails.dpdk.org (Postfix) with ESMTP id 03FA943295 for ; Fri, 15 Nov 2024 21:08:10 +0100 (CET) Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7ea7e2ff5ceso1683806a12.2 for ; Fri, 15 Nov 2024 12:08:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731701289; x=1732306089; 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=tmet1Afzp+Ly93FMmLH+Jw3kE/uX8dEKr+vfzTgvsB8=; b=beGy+RmDpyenTTwih+bjPdX/gxFUEl0isel1rSPBsw0PvgX+CLE0KrD0wZzWAYgG+m dV8cuWwG2eNs+eXmqqljHWZSc4fJRrz8kamsXZn6vKA/EZcfcy8cB2w8ZASilmeR7QID c/FERSNELHdpNzmcvHcd0ICIRvtW/XZLcKZGzAMDssBj46XqZjhjCKVt2E5nrMvpurf4 bY9+qUYmN7AALrM8YG5QLTtqQGp1BnEcT4C6zqqg1qTQqnj28AAGWpD5ldRAnAXj9Xvi AjaXiRNOgjECsDY+kXaOc1MgNzQ8ujtbGd5G9kP2+mbD3keHjUxqQmN7EZGQShsuc3M5 2vjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731701289; x=1732306089; 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=tmet1Afzp+Ly93FMmLH+Jw3kE/uX8dEKr+vfzTgvsB8=; b=EdLChwI6ew+Yf0NB6MW8VB+dWsDBrbe+fwh68D4wiyHG1AvMLPDcvUQ+reXtIH19ou JfD5h9TXE0StNrO5KZtePxB3mu1D5CRvdyIPJf79wda9zcG57Q3ds4voXZkPCsjl1Yiu 8UqeOLzR11T9au9Bp/r68xh3p0Lt65f+fW6JsZVGEtuKJf3TWNg+/qgChKGh+LYeJMPf OZ25rddqYJW4BvlXT95zM4oYxAXDBo8ZkP8EjFkHM/bIhqp+sEc4+Ghn5mMgyGZQVc0o h3UCnjkqb+rEdA7MvFl+MjtWD8jiPr5EOvRROgC031CBzZ8u2jmRMx5De0KKQPoqlpL0 awNA== X-Forwarded-Encrypted: i=1; AJvYcCUgAxZx4qZmiHo3+Kfr64soqJRDP03XXWEUVcdnQVpCCvVuZmB9fGSGyhD1c4w1lAolUonBv48=@dpdk.org X-Gm-Message-State: AOJu0YzTXgRXi+2MQlSioPb0cl6xrd1Q8V4hfMvKoiZQo+O+90DSWkOa 993SvkRbhupNbcvB77gP56bYBj3PDWG1vwujF8RQJi8An0z9NMiVRi3tLu79IQo= X-Google-Smtp-Source: AGHT+IEz0kOlDn3BDBz290LGKsxfyvHhangUpuDrbHygLrY/IasCrLAWlEekAx8+VnVoIPSe/eikvw== X-Received: by 2002:a05:6a21:c214:b0:1d9:386d:9441 with SMTP id adf61e73a8af0-1dc90b267fcmr3666309637.10.1731701289212; Fri, 15 Nov 2024 12:08:09 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724771e11f0sm1759686b3a.131.2024.11.15.12.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 12:08:08 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , getelson@nvidia.com, stable@dpdk.org, Bruce Richardson , Ori Kam , Aman Singh Subject: [PATCH v3 09/10] app/test-pmd: avoid potential outside of array reference Date: Fri, 15 Nov 2024 12:06:53 -0800 Message-ID: <20241115200751.17141-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241115200751.17141-1-stephen@networkplumber.org> References: <20241114001403.147609-1-stephen@networkplumber.org> <20241115200751.17141-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 Acked-by: Bruce Richardson --- 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