diff options
author | Dmitry Safonov <0x7f454c46@gmail.com> | 2024-04-13 03:42:54 +0200 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-04-16 13:35:06 +0200 |
commit | beb78cd1329d039d73487ca05633d1b92e1ab2ea (patch) | |
tree | 6e1e56bacbacd1168a89cbc9acf10eaf07e5d750 | |
parent | selftests/tcp_ao: Zero-init tcp_ao_info_opt (diff) | |
download | linux-beb78cd1329d039d73487ca05633d1b92e1ab2ea.tar.xz linux-beb78cd1329d039d73487ca05633d1b92e1ab2ea.zip |
selftests/tcp_ao: Fix fscanf() call for format-security
On my new laptop with packages from nixos-unstable, gcc 12.3.0 produces:
> lib/proc.c: In function ‘netstat_read_type’:
> lib/proc.c:89:9: error: format not a string literal and no format arguments [-Werror=format-security]
> 89 | if (fscanf(fnetstat, type->header_name) == EOF)
> | ^~
> cc1: some warnings being treated as errors
Here the selftests lib parses header name, while expectes non-space word
ending with a column.
Fixes: cfbab37b3da0 ("selftests/net: Add TCP-AO library")
Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r-- | tools/testing/selftests/net/tcp_ao/lib/proc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/net/tcp_ao/lib/proc.c b/tools/testing/selftests/net/tcp_ao/lib/proc.c index 2fb6dd8adba6..8b984fa04286 100644 --- a/tools/testing/selftests/net/tcp_ao/lib/proc.c +++ b/tools/testing/selftests/net/tcp_ao/lib/proc.c @@ -86,7 +86,7 @@ static void netstat_read_type(FILE *fnetstat, struct netstat **dest, char *line) pos = strchr(line, ' ') + 1; - if (fscanf(fnetstat, type->header_name) == EOF) + if (fscanf(fnetstat, "%[^ :]", type->header_name) == EOF) test_error("fscanf(%s)", type->header_name); if (fread(&tmp, 1, 1, fnetstat) != 1 || tmp != ':') test_error("Unexpected netstat format (%c)", tmp); |