From: Ursula Braun <ubraun@linux.vnet.ibm.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Ursula Braun <ursula.braun@de.ibm.com>,
Frank Blaschka <blaschka@linux.vnet.ibm.com>,
linux390@de.ibm.com, Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] s390: net: ctcm_main.c: Cleaning up missing null-terminate in conjunction with strncpy
Date: Tue, 29 Jul 2014 15:11:03 +0200 [thread overview]
Message-ID: <1406639463.13705.9.camel@BR9GV9YG.de.ibm.com> (raw)
In-Reply-To: <1406385234-3123-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
On Sat, 2014-07-26 at 16:33 +0200, Rickard Strandqvist wrote:
> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> drivers/s390/net/ctcm_main.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
> index 03b6ad0..670fa7d 100644
> --- a/drivers/s390/net/ctcm_main.c
> +++ b/drivers/s390/net/ctcm_main.c
> @@ -204,8 +204,8 @@ static void channel_remove(struct channel *ch)
>
> if (ch == NULL)
> return;
> - else
> - strncpy(chid, ch->id, CTCM_ID_SIZE);
> +
> + strlcpy(chid, ch->id, CTCM_ID_SIZE);
>
> channel_free(ch);
> while (*c) {
It is guaranteed that the string ch->id always fits into CTCM_ID_SIZE.
What's in this case the benefit of replacing strncpy() by strlcpy()
here?
I agree to remove the useless "else".
next prev parent reply other threads:[~2014-07-29 13:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-26 14:33 [PATCH] s390: net: ctcm_main.c: Cleaning up missing null-terminate in conjunction with strncpy Rickard Strandqvist
2014-07-29 13:11 ` Ursula Braun [this message]
[not found] ` <CAFo99gb2sSHVhDG0x6FzYi+YcKT7hQnu7qmUG=kaXyNaq4vKzw@mail.gmail.com>
2014-07-29 14:35 ` Heiko Carstens
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=1406639463.13705.9.camel@BR9GV9YG.de.ibm.com \
--to=ubraun@linux.vnet.ibm.com \
--cc=blaschka@linux.vnet.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=schwidefsky@de.ibm.com \
--cc=ursula.braun@de.ibm.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