public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] s390: net: ctcm_main.c:  Cleaning up missing null-terminate in conjunction with strncpy
@ 2014-07-26 14:33 Rickard Strandqvist
  2014-07-29 13:11 ` Ursula Braun
  0 siblings, 1 reply; 3+ messages in thread
From: Rickard Strandqvist @ 2014-07-26 14:33 UTC (permalink / raw)
  To: Ursula Braun, Frank Blaschka
  Cc: Rickard Strandqvist, linux390, Martin Schwidefsky, Heiko Carstens,
	linux-s390, linux-kernel

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) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] s390: net: ctcm_main.c:  Cleaning up missing null-terminate in conjunction with strncpy
  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
       [not found]   ` <CAFo99gb2sSHVhDG0x6FzYi+YcKT7hQnu7qmUG=kaXyNaq4vKzw@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Ursula Braun @ 2014-07-29 13:11 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Ursula Braun, Frank Blaschka, linux390, Martin Schwidefsky,
	Heiko Carstens, linux-s390, linux-kernel

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".

 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] s390: net: ctcm_main.c: Cleaning up missing null-terminate in conjunction with strncpy
       [not found]   ` <CAFo99gb2sSHVhDG0x6FzYi+YcKT7hQnu7qmUG=kaXyNaq4vKzw@mail.gmail.com>
@ 2014-07-29 14:35     ` Heiko Carstens
  0 siblings, 0 replies; 3+ messages in thread
From: Heiko Carstens @ 2014-07-29 14:35 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Ursula Braun, Martin Schwidefsky, Frank Blaschka, linux-s390,
	linux390, Ursula Braun, linux-kernel

On Tue, Jul 29, 2014 at 03:19:47PM +0200, Rickard Strandqvist wrote:
> > 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?
> 
> If it is really so! It can just as well replacing it with strcpy...

Or.. just leave the code alone.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-29 14:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
     [not found]   ` <CAFo99gb2sSHVhDG0x6FzYi+YcKT7hQnu7qmUG=kaXyNaq4vKzw@mail.gmail.com>
2014-07-29 14:35     ` Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox