Thread (2 messages) flat view 2 messages, 2 authors, 2026-03-17

Re: [PATCH] lib/bootconfig: guard xbc_node_compose_key_after() buffer size

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2026-03-17 18:02:25
Also in: lkml

On Tue, 17 Mar 2026 17:37:03 +0000
Josh Law [off-list ref] wrote:
quoted hunk ↗ jump to hunk
@@ -313,13 +313,16 @@ int __init xbc_node_compose_key_after(struct xbc_node *root,
 	if (!node && root)
 		return -EINVAL;
 
+	if (WARN_ON_ONCE(size > INT_MAX))
+		return -EINVAL;
+
 	while (--depth >= 0) {
 		node = xbc_nodes + keys[depth];
 		ret = snprintf(buf, size, "%s%s", xbc_node_get_data(node),
 			       depth ? "." : "");
 		if (ret < 0)
 			return ret;
-		if (ret >= (int)size) {
+		if ((size_t)ret >= size) {
Hmm, if size can't be greater than INT_MAX, this code should be able to
stay the same.

-- Steve

 			size = 0;
 		} else {
 			size -= (size_t)ret;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help