DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: dev@dpdk.org
Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Andy Moreton <amoreton@xilinx.com>
Subject: [dpdk-dev] [PATCH 2/2] net/sfc: use more robust string comparison
Date: Mon,  9 Nov 2020 14:46:06 +0300	[thread overview]
Message-ID: <20201109114606.23876-2-ivan.malov@oktetlabs.ru> (raw)
In-Reply-To: <20201109114606.23876-1-ivan.malov@oktetlabs.ru>

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 <ivan.malov@oktetlabs.ru>
---
 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


  reply	other threads:[~2020-11-09 11:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 11:46 [dpdk-dev] [PATCH 1/2] common/sfc_efx/base: apply MCDI version/boot clarity fixes Ivan Malov
2020-11-09 11:46 ` Ivan Malov [this message]
2020-11-09 11:49   ` [dpdk-dev] [PATCH 2/2] net/sfc: use more robust string comparison Andrew Rybchenko
2020-11-09 11:49 ` [dpdk-dev] [PATCH 1/2] common/sfc_efx/base: apply MCDI version/boot clarity fixes Andrew Rybchenko
2020-11-10  9:53   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201109114606.23876-2-ivan.malov@oktetlabs.ru \
    --to=ivan.malov@oktetlabs.ru \
    --cc=amoreton@xilinx.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).