mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: linux-hardening@vger.kernel.org, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: RB532: Replace deprecated strcpy() with memcpy() and strscpy()
Date: Fri, 29 Aug 2025 12:28:03 +0200	[thread overview]
Message-ID: <aLGAs9qSe3KSzh_P@alpha.franken.de> (raw)
In-Reply-To: <20250819102419.712031-2-thorsten.blum@linux.dev>

On Tue, Aug 19, 2025 at 12:24:17PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use memcpy() and strscpy() instead.
> 
> Add the local variable 'size_t len' to keep track of the string lengths
> and prefer memcpy() over strscpy() when we use the string length to
> advance the 'cp' pointer.
> 
> No functional changes intended.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/rb532/prom.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/mips/rb532/prom.c b/arch/mips/rb532/prom.c
> index b88e89ec5894..8c370eb180ef 100644
> --- a/arch/mips/rb532/prom.c
> +++ b/arch/mips/rb532/prom.c
> @@ -53,6 +53,7 @@ static void __init prom_setup_cmdline(void)
>  	int prom_argc;
>  	char **prom_argv;
>  	int i;
> +	size_t len;
>  
>  	prom_argc = fw_arg0;
>  	prom_argv = (char **) fw_arg1;
> @@ -82,20 +83,20 @@ static void __init prom_setup_cmdline(void)
>  				mips_machtype = MACH_MIKROTIK_RB532;
>  		}
>  
> -		strcpy(cp, prom_argv[i]);
> -		cp += strlen(prom_argv[i]);
> +		len = strlen(prom_argv[i]);
> +		memcpy(cp, prom_argv[i], len + 1);
> +		cp += len;
>  	}
>  	*(cp++) = ' ';
>  
> -	i = strlen(arcs_cmdline);
> -	if (i > 0) {
> +	len = strlen(arcs_cmdline);
> +	if (len > 0) {
>  		*(cp++) = ' ';
> -		strcpy(cp, arcs_cmdline);
> -		cp += strlen(arcs_cmdline);
> +		memcpy(cp, arcs_cmdline, len + 1);
> +		cp += len;
>  	}
>  	cmd_line[COMMAND_LINE_SIZE - 1] = '\0';
> -
> -	strcpy(arcs_cmdline, cmd_line);
> +	strscpy(arcs_cmdline, cmd_line);
>  }
>  
>  void __init prom_init(void)
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

      reply	other threads:[~2025-08-29 10:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19 10:24 Thorsten Blum
2025-08-29 10:28 ` Thomas Bogendoerfer [this message]

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=aLGAs9qSe3KSzh_P@alpha.franken.de \
    --to=tsbogend@alpha.franken.de \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=thorsten.blum@linux.dev \
    /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

all inboxes | Powered by JetHome®