Re: [PATCH bpf-next v1 1/4] selftests/bpf: NUL-terminate bpftool command output
Eduard Zingerman <[email protected]>
| Newsgroups | org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2026-08-19 at 17:06 -0700, Ihor Solodrai wrote:
> run_command() writes a bpftool command's output into a caller-supplied
> buffer, and every caller treats that buffer as a C string.
>
> However fread() reports a byte count and doesn't terminate the
> string. The helper does not terminate either, so callers have to zero
> the buffer first. prog_tests/bpftool_metadata.c does not, for example.
>
> Read one byte less and terminate in the helper.
>
> Fixes: f21fae577446 ("selftests/bpf: Add a few helpers for bpftool testing")
> Signed-off-by: Ihor Solodrai <[email protected]>
> ---
Acked-by: Eduard Zingerman <[email protected]>
...