linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Daniel Walker <danielwa@cisco.com>, Will Deacon <will@kernel.org>,
	ob Herring <robh@kernel.org>,
	Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>,
	Andrew Morton <akpm@linux-foundation.org>,
	x86@kernel.org, linux-mips@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org
Cc: xe-linux-external@cisco.com,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/8] powerpc: convert strcpy to strlcpy in prom_init
Date: Fri, 2 Apr 2021 19:32:33 +0200	[thread overview]
Message-ID: <d7b0b382-056f-d800-d96a-adc0338378a2@csgroup.eu> (raw)
In-Reply-To: <0c80a08ad4cf788c75043c1615c05bad893f4fde.1617126961.git.danielwa@cisco.com>



Le 30/03/2021 à 19:56, Daniel Walker a écrit :
> There's only two users of strcpy and one is the command
> line handling. The generic command line handling uses strlcpy
> and it makes sense to convert this one other user to strlcpy to
> keep prom_init size consistent.
> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/prom_init.c | 25 +++++++++++++++----------
>   1 file changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> index ccf77b985c8f..2c2f33155317 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -242,15 +242,6 @@ static int __init prom_strcmp(const char *cs, const char *ct)
>   	return 0;
>   }
>   
> -static char __init *prom_strcpy(char *dest, const char *src)
> -{
> -	char *tmp = dest;
> -
> -	while ((*dest++ = *src++) != '\0')
> -		/* nothing */;
> -	return tmp;
> -}
> -
>   static int __init prom_strncmp(const char *cs, const char *ct, size_t count)
>   {
>   	unsigned char c1, c2;
> @@ -276,6 +267,20 @@ static size_t __init prom_strlen(const char *s)
>   	return sc - s;
>   }
>   
> +static size_t __init prom_strlcpy(char *dest, const char *src, size_t size)
> +{
> +	size_t ret = prom_strlen(src);
> +
> +	if (size) {
> +		size_t len = (ret >= size) ? size - 1 : ret;
> +
> +		memcpy(dest, src, len);
> +		dest[len] = '\0';
> +	}
> +	return ret;
> +}
> +
> +
>   static int __init prom_memcmp(const void *cs, const void *ct, size_t count)
>   {
>   	const unsigned char *su1, *su2;
> @@ -2702,7 +2707,7 @@ static void __init flatten_device_tree(void)
>   
>   	/* Add "phandle" in there, we'll need it */
>   	namep = make_room(&mem_start, &mem_end, 16, 1);
> -	prom_strcpy(namep, "phandle");
> +	prom_strlcpy(namep, "phandle", 8);
>   	mem_start = (unsigned long)namep + prom_strlen(namep) + 1;
>   
>   	/* Build string array */
> 

  reply	other threads:[~2021-04-02 17:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 17:56 [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
2021-03-30 17:56 ` [PATCH 2/8] CMDLINE: drivers: of: ifdef out cmdline section Daniel Walker
2021-03-30 19:49   ` Rob Herring
2021-03-30 23:17     ` Daniel Walker
2021-04-07 22:59       ` Rob Herring
2021-04-09  1:26         ` Daniel Walker
2021-04-02 17:32   ` Christophe Leroy
2021-04-06 16:35     ` Daniel Walker
2021-03-30 17:56 ` [PATCH 3/8] powerpc: convert strcpy to strlcpy in prom_init Daniel Walker
2021-04-02 17:32   ` Christophe Leroy [this message]
2021-03-30 17:56 ` [PATCH 4/8] CMDLINE: powerpc: convert to generic builtin command line Daniel Walker
2021-04-02 17:34   ` Christophe Leroy
2021-04-06 16:38     ` Daniel Walker
2021-03-30 17:57 ` [PATCH 5/8] CMDLINE: mips: " Daniel Walker
2021-03-30 17:57 ` [PATCH 6/8] drivers: firmware: efi: libstub: enable generic commandline Daniel Walker
2021-03-31 16:10   ` Ard Biesheuvel
2021-03-31 18:21     ` Daniel Walker
2021-04-02 17:36   ` Christophe Leroy
2021-04-06 16:42     ` Daniel Walker
2021-03-30 17:57 ` [PATCH 7/8] CMDLINE: x86: convert to generic builtin command line Daniel Walker
2021-03-30 17:57 ` [PATCH 8/8] CMDLINE: arm64: " Daniel Walker
2021-04-02 17:28 ` [PATCH 1/8] CMDLINE: add " Christophe Leroy

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=d7b0b382-056f-d800-d96a-adc0338378a2@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=daniel@gimpelevich.san-francisco.ca.us \
    --cc=danielwa@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=robh@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=xe-linux-external@cisco.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;
as well as URLs for NNTP newsgroup(s).