* [PATCH] w1: validate slave string length before checking separator
@ 2026-06-30 6:57 Pengpeng Hou
2026-07-03 9:41 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-30 6:57 UTC (permalink / raw)
To: Krzysztof Kozlowski; +Cc: linux-kernel, Pengpeng Hou
w1_atoreg_num() checks buf[2] for the family/id separator before proving
the input contains that byte.
Require at least the family and separator prefix before checking the
separator.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
drivers/w1/w1.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 486f321..c169466 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -403,6 +403,11 @@ static int w1_atoreg_num(struct device *dev, const char *buf, size_t count,
const char *error_msg = "bad slave string format, expecting "
"ff-dddddddddddd\n";
+ if (count < 3) {
+ dev_err(dev, "%s", error_msg);
+ return -EINVAL;
+ }
+
if (buf[2] != '-') {
dev_err(dev, "%s", error_msg);
return -EINVAL;
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-03 9:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 6:57 [PATCH] w1: validate slave string length before checking separator Pengpeng Hou
2026-07-03 9:41 ` Krzysztof Kozlowski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.