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 A8B6945D66 for ; Thu, 21 Nov 2024 19:25:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A339A4326E; Thu, 21 Nov 2024 19:25:11 +0100 (CET) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id 2277343003 for ; Thu, 21 Nov 2024 19:25:03 +0100 (CET) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-724a96f188cso1159512b3a.1 for ; Thu, 21 Nov 2024 10:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1732213502; x=1732818302; 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=estCbK08f3Ij0JF/UnOS2M28Y+Mm7g2IiXjlIb3UVwqarbPeMpetHXwmqjsJCZswR6 wS7t92SyqhypVhDJj9jEbAmAdUQw2qwIJD2AvUX+qbMWztgTcm8mgzNWbOV7B8Tn7L9K PgxTC+KTmE042dbxxhdNAMzLuqs+Oco+hvOgTyYCL6m9x0PRWw/DqP24+30QgZeO524I 1i8r9vKw9pryFrs75npQfd03uKJikTuh4h+/yyd8Y4gglb0C/qpIK6cUwA2t7f1ipzMt ImfVzU40hpFrKxLF6gJYH9ZvW5UgJ6FuQFIIana7AaTzE/Axflm7/PpiaoV7KOW/6EhA 7dFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732213502; x=1732818302; 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=PyjB9MlixoyqW/iJTrkebKdrvineGbsYqsWAOt/JAl11n4dGXSsmO6cm7wNfI0bAl4 kQ3hwZHQaD4XF0wcPuLoTtXL10YM2X6PP6WnCA0UTF8iaLzpHsjgojISWqytc010HxzT uDTA2EIzrkvu8w9+VhDS00sZ7KwTQYlEYIuATnd3j24QmXGIJAM0bMxaU/GZKv+0TGTt 9lmt0dBAdrj3CUuHyyUCsY9EviEHXdmAqVspEFbq3evncCs3yHvmq7+g9S1KH6MQpbcU YY5nOeMiujkt/bdzRCiRC8NsXrddAJ6P3fmXuYo+y7gSgbglWX7rpzQR+ZLvi3dGUPyf lWSA== X-Forwarded-Encrypted: i=1; AJvYcCWnjABRCHUVRwKyYD5pYJf/u36B2jy7b4oIo5dEQQRz/l+Hg6WprTeyj1B1cBPyExLCnBEOb3c=@dpdk.org X-Gm-Message-State: AOJu0YwgdAT+ttlGabSCWAH3owE2BjuIUUvGJjok/dmtbGEQF9PLVFXQ 44aAE6vx0hoEtCwTaVp/QagFhocs7fDd74JlC5Yic0NztPKI0urP5UKW3+se3ZPSSdlcrJsDHBQ +/Qw= X-Gm-Gg: ASbGncvaEe4lj5yHICpdZYKwptXIR1agliOrohmMWFeff0FdQIafdZL6Xe+brltOd/3 mxxAACiUo51bbfGRAIW195YXF+quS8Msw56xX+uMgE54ScnXmNU2vAOZQyShrioHw1WwjdPCTF7 ZLt+4tblfCC3qKqOVHX6UNXqvSEnAIX9+vhVqCpOF8jAfn8v+mSxgJd2aSQwkh6nqDv70qR7AjP YcbM+R62s4d+A5lxOJJPYbHrW2YMfuYqC1fLMSlNYPGCikRB/0ajxtFQ1YXCvMS/TB4x5/4hFX4 G076b4HwG/yHfXtesVc6PDQlP+4= X-Google-Smtp-Source: AGHT+IEDOy4uWn0rPqxWvKT0LWkqpEbGTIfxFwN2BVwHyaHRD3fbsahioQQk7zo8vKoD4+ncYqcXbw== X-Received: by 2002:a05:6a00:9a0:b0:71e:3b51:e856 with SMTP id d2e1a72fcca58-724df3c77a5mr847b3a.1.1732213502223; Thu, 21 Nov 2024 10:25:02 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724de454aa1sm70201b3a.4.2024.11.21.10.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 10:25:01 -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 v4 9/9] app/test-pmd: avoid potential outside of array reference Date: Thu, 21 Nov 2024 10:23:30 -0800 Message-ID: <20241121182443.68025-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241121182443.68025-1-stephen@networkplumber.org> References: <20241114001403.147609-1-stephen@networkplumber.org> <20241121182443.68025-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