public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
	Huisong Li <lihuisong@huawei.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] w1: therm: Replace deprecated strcpy with strscpy in alarms_store
Date: Wed, 22 Oct 2025 17:50:59 +0100	[thread overview]
Message-ID: <20251022175059.7653c2e0@pumpkin> (raw)
In-Reply-To: <db33871a-26ad-44f2-8e4b-046aa34f6477@kernel.org>

On Mon, 20 Oct 2025 09:01:08 +0200
Krzysztof Kozlowski <krzk@kernel.org> wrote:

> On 17/10/2025 19:00, Thorsten Blum wrote:
> > strcpy() is deprecated because it can overflow when the destination
> > buffer is not large enough for the source string. Replace it with  
> 
> It cannot overflow. Look at the code - memory is allocated for the size.
> 
> > strscpy(), which avoids overflows and guarantees NUL-termination.  
> 
> Maybe NUL-termination is missing, could be.
> 
> Anyway please write commit msg describing this exact code, not a generic
> one for work replacing strcpy(). Your generic commit msg is just not
> applicable here.
> 
> And even there, just look at the code - why exactly cannot it be
> simplified into ksrtdup?

Or use a different function for numeric conversion that behaves like
the userspace strtoul() family and returns a pointer to the character
that fails the conversion - and then check it is a space.

Then there isn't any need to copy the string at all.

	David

> 
> 
> 
> Best regards,
> Krzysztof
> 


      parent reply	other threads:[~2025-10-22 16:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 17:00 [PATCH] w1: therm: Replace deprecated strcpy with strscpy in alarms_store Thorsten Blum
2025-10-20  7:01 ` Krzysztof Kozlowski
2025-10-21 21:22   ` Thorsten Blum
2025-10-22 16:50   ` David Laight [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=20251022175059.7653c2e0@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=krzk@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lihuisong@huawei.com \
    --cc=linux-kernel@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