From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Siddarth Gundu <siddarthsgml@gmail.com>
Cc: linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] m68k: apollo: replace strcpy() with strscpy()
Date: Wed, 14 May 2025 09:10:17 +0200 [thread overview]
Message-ID: <CAMuHMdXxDPDQVwx_9Z6ngvs4sYro3cobE=YP0y-b0zs0ody2vg@mail.gmail.com> (raw)
In-Reply-To: <20250514052327.96537-1-siddarthsgml@gmail.com>
Hi Siddarth,
Thanks for your patch!
On Wed, 14 May 2025 at 07:23, Siddarth Gundu <siddarthsgml@gmail.com> wrote:
> strcpy() is deprecated; use strscpy() instead.
>
> strscpy was chosen because the code expects a NUL-terminated string
> without zero-padding.
... which are not sufficient reasons: there is no size information
about the destination buffer.
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Siddarth Gundu <siddarthsgml@gmail.com>
> --- a/arch/m68k/apollo/config.c
> +++ b/arch/m68k/apollo/config.c
> @@ -218,7 +219,7 @@ static void dn_dummy_reset(void)
>
> static void dn_get_model(char *model)
> {
> - strcpy(model, "Apollo ");
> + strscpy(model, "Apollo ");
include/linux/compiler.h:197:62: error: static assertion failed: "must be array"
[...]
arch/m68k/apollo/config.c:222:5: note: in expansion of macro ‘strscpy’
222 | strscpy(model, "Apollo ");
| ^~~~~~~
Please try to (at least) test-compile your patches before submitting.
> if (apollo_model >= APOLLO_DN3000 && apollo_model <= APOLLO_DN4500)
> strcat(model, apollo_models[apollo_model - APOLLO_DN3000]);
FWIW, if the strscpy() would have prevented a buffer overflow, the
strcat() would still cause one. But none of these can happen for real.
> }
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2025-05-14 7:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 5:23 [PATCH] m68k: apollo: replace strcpy() with strscpy() Siddarth Gundu
2025-05-14 7:10 ` Geert Uytterhoeven [this message]
2025-05-20 11:38 ` kernel test robot
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='CAMuHMdXxDPDQVwx_9Z6ngvs4sYro3cobE=YP0y-b0zs0ody2vg@mail.gmail.com' \
--to=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=siddarthsgml@gmail.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).