* [PATCH net-next v1] tools: ynl-gen: validate 0 len strings from kernel
@ 2025-05-03 4:30 David Wei
2025-05-06 1:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: David Wei @ 2025-05-03 4:30 UTC (permalink / raw)
To: netdev
Cc: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Jacob Keller
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>
---
tools/net/ynl/lib/ynl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/net/ynl/lib/ynl.c b/tools/net/ynl/lib/ynl.c
index d263f6f40ad5..a0b54ad4c073 100644
--- a/tools/net/ynl/lib/ynl.c
+++ b/tools/net/ynl/lib/ynl.c
@@ -364,7 +364,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);
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v1] tools: ynl-gen: validate 0 len strings from kernel
2025-05-03 4:30 [PATCH net-next v1] tools: ynl-gen: validate 0 len strings from kernel David Wei
@ 2025-05-06 1:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-06 1:20 UTC (permalink / raw)
To: David Wei
Cc: netdev, donald.hunter, kuba, davem, edumazet, pabeni, horms,
jacob.e.keller
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 2 May 2025 21:30:50 -0700 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [net-next,v1] tools: ynl-gen: validate 0 len strings from kernel
https://git.kernel.org/netdev/net/c/4720f9707c78
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-06 1:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-03 4:30 [PATCH net-next v1] tools: ynl-gen: validate 0 len strings from kernel David Wei
2025-05-06 1:20 ` patchwork-bot+netdevbpf
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.