riscv: Pass correct size to snprintf()
The snprintf() function does not get the correct size argument passed,
when the FDT ISA string is built. Instead of adjusting the size for
each extension, the full size is passed for every iteration. Doing so
will make __snprinf_chk() bail out on glibc.
Adjust size for each iteration.
Fixes: 8aff29e1dafe ("riscv: Append ISA extensions to the device tree")
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Link: https://lore.kernel.org/r/20241104192120.75841-1-bjorn@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
diff --git a/riscv/fdt.c b/riscv/fdt.c
index 8189601..85c8f95 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -157,7 +157,7 @@
isa_info_arr[i].name);
break;
}
- pos += snprintf(cpu_isa + pos, CPU_ISA_MAX_LEN, "_%s",
+ pos += snprintf(cpu_isa + pos, CPU_ISA_MAX_LEN - pos, "_%s",
isa_info_arr[i].name);
}
cpu_isa[pos] = '\0';