diff options
| author | Masami Hiramatsu (Google) <mhiramat@kernel.org> | 2026-11-22 10:01:50 +0900 |
|---|---|---|
| committer | Masami Hiramatsu (Google) <mhiramat@kernel.org> | 2026-11-22 16:23:35 +0900 |
| commit | 919165d94fb4aeb2e41b6d0a60118750b1f75f26 (patch) | |
| tree | b86bef02c49fd694fd5feac8b4918cd574e66709 /tools/perf/scripts/python | |
| parent | 2913c7c94b786a7193faf67390a305895b8180ee (diff) | |
bootconfig: Avoid out-of-bounds pointer arithmetic in xbc_snprint_cmdline_filter()
xbc_snprint_cmdline_filter() passes `buf ? buf + len : NULL` to
snprintf(). While this avoids NULL pointer arithmetic when @buf is NULL,
if @buf is non-NULL and the rendered output exceeds @size (len > size),
evaluating `buf + len` forms a pointer past the end of the @buf
allocation, which is undefined behavior in C even though rest(len, size)
is 0.
Pass `buf && len < size ? buf + len : NULL` so that snprintf() receives
NULL whenever the remaining buffer capacity is 0.
Link: https://lore.kernel.org/all/179530931041.109991.12049130742435464205.stgit@devnote2/
Fixes: dec4d8118c17 ("bootconfig: fix NULL-pointer arithmetic in xbc_snprint_cmdline()")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
