linux/tools/lib/api
Arnaldo Carvalho de Melo fd1f70776a tools lib api: Fix mount_overload() snprintf truncation and toupper range
mount_overload() builds an environment variable name like
"PERF_SYSFS_ENVIRONMENT" from fs->name.  Two bugs:

1) snprintf() uses name_len as the buffer size instead of sizeof(upper_name).
   For fs->name = "sysfs" (len=5), the output is truncated to "PERF" (4
   chars + null), so getenv() never finds the intended variable.

2) mem_toupper() only uppercases name_len bytes, converting just the "PERF"
   prefix rather than the full string including the filesystem name portion.

Fix by using sizeof(upper_name) for snprintf and strlen(upper_name) for
mem_toupper, so the full "PERF_SYSFS_ENVIRONMENT" string is correctly
formatted and uppercased.

Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Fixes: 73ca85ad36 ("tools lib api fs: Add FSTYPE__mount() method")
Cc: Jiri Olsa <jolsa@kernel.org>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-06-10 18:56:02 -03:00
..
fd perf record: Fix way of handling non-perf-event pollfds 2022-10-04 08:55:19 -03:00
fs tools lib api: Fix mount_overload() snprintf truncation and toupper range 2026-06-10 18:56:02 -03:00
Build
cpu.c
cpu.h
debug-internal.h
debug.c
debug.h
io_dir.h libapi: Add missing header with NAME_MAX define to io_dir.h 2025-03-13 00:29:36 -07:00
io.h tools api io: Ensure line_len_out is always initialized 2024-11-08 22:46:44 -08:00
Makefile tools lib api: Add io_dir an allocation free readdir alternative 2025-02-24 15:46:33 -08:00