mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
w1: validate slave string length before checking separator
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> Link: https://patch.msgid.link/2026063007047999.4-ccfa108-0039-w1-validate-slave-string-le-pengpeng@iscas.ac.cn Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
This commit is contained in:
committed by
Krzysztof Kozlowski
parent
169ae5e65e
commit
73f46553fd
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user