public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: Krzysztof Kozlowski <krzk@kernel.org>, Huisong Li <lihuisong@huawei.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] w1: therm: Replace deprecated strcpy with strscpy in alarms_store
Date: Fri, 17 Oct 2025 19:00:43 +0200	[thread overview]
Message-ID: <20251017170047.114224-2-thorsten.blum@linux.dev> (raw)

strcpy() is deprecated because it can overflow when the destination
buffer is not large enough for the source string. Replace it with
strscpy(), which avoids overflows and guarantees NUL-termination.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/w1/slaves/w1_therm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 9ccedb3264fb..fcd7aab5b52d 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -1849,7 +1849,7 @@ static ssize_t alarms_store(struct device *device,
 			__func__, -ENOMEM);
 		return size;
 	}
-	strcpy(p_args, buf);
+	strscpy(p_args, buf, size);
 
 	/* Split string using space char */
 	token = strsep(&p_args, " ");
-- 
2.51.0


             reply	other threads:[~2025-10-17 17:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 17:00 Thorsten Blum [this message]
2025-10-20  7:01 ` [PATCH] w1: therm: Replace deprecated strcpy with strscpy in alarms_store Krzysztof Kozlowski
2025-10-21 21:22   ` Thorsten Blum
2025-10-22 16:50   ` David Laight

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=20251017170047.114224-2-thorsten.blum@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=krzk@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lihuisong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    /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