mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-14 11:19:08 +10:00
tools: ynl-gen: validate 0 len strings from kernel
[ Upstream commit 4720f9707c
]
Strings from the kernel are guaranteed to be null terminated and
ynl_attr_validate() checks for this. But it doesn't check if the string
has a len of 0, which would cause problems when trying to access
data[len - 1]. Fix this by checking that len is positive.
Signed-off-by: David Wei <dw@davidwei.uk>
Link: https://patch.msgid.link/20250503043050.861238-1-dw@davidwei.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
50d0de59f6
commit
4e3401aa6e
@ -368,7 +368,7 @@ int ynl_attr_validate(struct ynl_parse_arg *yarg, const struct nlattr *attr)
|
||||
"Invalid attribute (binary %s)", policy->name);
|
||||
return -1;
|
||||
case YNL_PT_NUL_STR:
|
||||
if ((!policy->len || len <= policy->len) && !data[len - 1])
|
||||
if (len && (!policy->len || len <= policy->len) && !data[len - 1])
|
||||
break;
|
||||
yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
|
||||
"Invalid attribute (string %s)", policy->name);
|
||||
|
Loading…
Reference in New Issue
Block a user