From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5610A0527; Mon, 9 Nov 2020 12:46:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0D6466A1B; Mon, 9 Nov 2020 12:46:39 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by dpdk.org (Postfix) with ESMTP id 39E076883 for ; Mon, 9 Nov 2020 12:46:36 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id E2C417F576; Mon, 9 Nov 2020 14:46:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E2C417F576 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1604922394; bh=rxbLtvVd3wGQzXAAjg/KeFIczPpCEzcKpvc4X9kQa0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E2I52ZzG7P813xMVFvpvHUgPZKsuHlS0K2fRT74yuW7EtcJBFfmmGRQuk+TfX1sTd OJ+tU5eVH2NmlTnnHsEct0ROY6umCbBVZLtUqyCDLYBXHkBambbEP9M0JPPzUGhlwT EGmxdoxpT1xSKMrXOXd3PT9AwdXIXLC9AxbjHfEs= From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton Date: Mon, 9 Nov 2020 14:46:06 +0300 Message-Id: <20201109114606.23876-2-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201109114606.23876-1-ivan.malov@oktetlabs.ru> References: <20201109114606.23876-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/2] net/sfc: use more robust string comparison X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When it comes to comparing HW switch ID strings, use strncmp to avoid reading past the buffer. Fixes: e86b48aa46d4 ("net/sfc: add HW switch ID helpers") Signed-off-by: Ivan Malov --- drivers/net/sfc/sfc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index a4fe49578..671a16640 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -1301,5 +1301,6 @@ bool sfc_hw_switch_ids_equal(const struct sfc_hw_switch_id *left, const struct sfc_hw_switch_id *right) { - return strcmp(left->board_sn, right->board_sn) == 0; + return strncmp(left->board_sn, right->board_sn, + sizeof(left->board_sn)) == 0; } -- 2.20.1