From: Yann Droneaud <ydroneaud@opteya.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Steve Wise <swise@chelsio.com>, Roland Dreier <roland@kernel.org>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Yann Droneaud <ydroneaud@opteya.com>
Subject: Re: [PATCH] infiniband: hw: cxgb3: cxio_hal.c: Cleaning up missing null-terminate after strncpy call
Date: Mon, 18 Aug 2014 15:30:08 +0200 [thread overview]
Message-ID: <1408368608.3030.4.camel@localhost.localdomain> (raw)
In-Reply-To: <1408315225-16807-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Hi,
Le lundi 18 août 2014 à 00:40 +0200, Rickard Strandqvist a écrit :
> Added a guaranteed null-terminate after call to strncpy.
>
Good catch. Do you have an automated way to catch such mistake ?
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> drivers/infiniband/hw/cxgb3/cxio_hal.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
> index de1c61b4..5fc04e4 100644
> --- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
> +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
> @@ -933,6 +933,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p)
> netdev_p = rdev_p->t3cdev_p->lldev;
> strncpy(rdev_p->dev_name, rdev_p->t3cdev_p->name,
> T3_MAX_DEV_NAME_LEN);
> + rdev_p->dev_name[T3_MAX_DEV_NAME_LEN - 1] = '\0';
Why not replacing this by
strlcpy(rdev_p->dev_name, rdev_p->t3cdev_p->name,
T3_MAX_DEV_NAME_LEN);
Regards.
--
Yann Droneaud
OPTEYA
next prev parent reply other threads:[~2014-08-18 13:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-17 22:40 [PATCH] infiniband: hw: cxgb3: cxio_hal.c: Cleaning up missing null-terminate after strncpy call Rickard Strandqvist
2014-08-18 13:30 ` Yann Droneaud [this message]
2014-08-18 14:27 ` Steve Wise
2014-08-18 16:25 ` Rickard Strandqvist
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=1408368608.3030.4.camel@localhost.localdomain \
--to=ydroneaud@opteya.com \
--cc=hal.rosenstock@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=roland@kernel.org \
--cc=sean.hefty@intel.com \
--cc=swise@chelsio.com \
/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