summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Law <objecting@objecting.org>2026-03-12 19:11:43 +0000
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>2026-03-13 17:48:27 +0900
commit1120a36bb1e9b9e22de75ecb4ef0b998f73a97f1 (patch)
treee3763927e2c2343b13c0196626f0f28e8a2c63ab
parent560f763baa0f2c9a44da4294c06af071405ac46f (diff)
lib/bootconfig: fix snprintf truncation check in xbc_node_compose_key_after()
snprintf() returns the number of characters that would have been written excluding the NUL terminator. Output is truncated when the return value is >= the buffer size, not just > the buffer size. When ret == size, the current code takes the non-truncated path, advancing buf by ret and reducing size to 0. This is wrong because the output was actually truncated (the last character was replaced by NUL). Fix by using >= so the truncation path is taken correctly. Link: https://lore.kernel.org/all/20260312191143.28719-4-objecting@objecting.org/ Fixes: 76db5a27a827 ("bootconfig: Add Extra Boot Config support") Cc: stable@vger.kernel.org Signed-off-by: Josh Law <objecting@objecting.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
-rw-r--r--lib/bootconfig.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 9c3d59fb96ed..2da049216fe0 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -316,7 +316,7 @@ int __init xbc_node_compose_key_after(struct xbc_node *root,
depth ? "." : "");
if (ret < 0)
return ret;
- if (ret > size) {
+ if (ret >= size) {
size = 0;
} else {
size -= ret;