Skip to content

Commit beb78cd

Browse files
0x7f454c46Paolo Abeni
authored and
Paolo Abeni
committed
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: cfbab37 ("selftests/net: Add TCP-AO library") Signed-off-by: Dmitry Safonov <[email protected]> Reported-by: Muhammad Usama Anjum <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent b089b3b commit beb78cd

File tree

1 file changed

+1
-1
lines changed
  • tools/testing/selftests/net/tcp_ao/lib

1 file changed

+1
-1
lines changed

tools/testing/selftests/net/tcp_ao/lib/proc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static void netstat_read_type(FILE *fnetstat, struct netstat **dest, char *line)
8686

8787
pos = strchr(line, ' ') + 1;
8888

89-
if (fscanf(fnetstat, type->header_name) == EOF)
89+
if (fscanf(fnetstat, "%[^ :]", type->header_name) == EOF)
9090
test_error("fscanf(%s)", type->header_name);
9191
if (fread(&tmp, 1, 1, fnetstat) != 1 || tmp != ':')
9292
test_error("Unexpected netstat format (%c)", tmp);

0 commit comments

Comments
 (0)