diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2021-08-21 02:19:49 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-08-24 23:48:40 +0200 |
commit | 50b796e645a5d217fd9d8648ec594241e6f1dd57 (patch) | |
tree | 13a16f17ec1aebbf52f772ca5bf38cf61efa0027 /samples/bpf/tracex4_user.c | |
parent | bpf: Fix possible out of bound write in narrow load handling (diff) | |
download | linux-50b796e645a5d217fd9d8648ec594241e6f1dd57.tar.xz linux-50b796e645a5d217fd9d8648ec594241e6f1dd57.zip |
samples: bpf: Fix a couple of warnings
cookie_uid_helper_example.c: In function ‘main’:
cookie_uid_helper_example.c:178:69: warning: ‘ -j ACCEPT’ directive
writing 10 bytes into a region of size between 8 and 58
[-Wformat-overflow=]
178 | sprintf(rules, "iptables -A OUTPUT -m bpf --object-pinned %s -j ACCEPT",
| ^~~~~~~~~~
/home/kkd/src/linux/samples/bpf/cookie_uid_helper_example.c:178:9: note:
‘sprintf’ output between 53 and 103 bytes into a destination of size 100
178 | sprintf(rules, "iptables -A OUTPUT -m bpf --object-pinned %s -j ACCEPT",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
179 | file);
| ~~~~~
Fix by using snprintf and a sufficiently sized buffer.
tracex4_user.c:35:15: warning: ‘write’ reading 12 bytes from a region of
size 11 [-Wstringop-overread]
35 | key = write(1, "\e[1;1H\e[2J", 12); /* clear screen */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Use size as 11.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210821002010.845777-2-memxor@gmail.com
Diffstat (limited to 'samples/bpf/tracex4_user.c')
-rw-r--r-- | samples/bpf/tracex4_user.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/samples/bpf/tracex4_user.c b/samples/bpf/tracex4_user.c index cea399424bca..566e6440e8c2 100644 --- a/samples/bpf/tracex4_user.c +++ b/samples/bpf/tracex4_user.c @@ -32,7 +32,7 @@ static void print_old_objects(int fd) __u64 key, next_key; struct pair v; - key = write(1, "\e[1;1H\e[2J", 12); /* clear screen */ + key = write(1, "\e[1;1H\e[2J", 11); /* clear screen */ key = -1; while (bpf_map_get_next_key(fd, &key, &next_key) == 0) { |