Skip to content

Commit

Permalink
tools resolve_btfids: Add size check to get_id function
Browse files Browse the repository at this point in the history
To make sure we don't crash on malformed symbols.

Signed-off-by: Jiri Olsa <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
olsajiri authored and Alexei Starovoitov committed Aug 25, 2020
1 parent 2532f84 commit 193a983
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/bpf/resolve_btfids/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,16 @@ static char *get_id(const char *prefix_end)
/*
* __BTF_ID__func__vfs_truncate__0
* prefix_end = ^
* pos = ^
*/
char *p, *id = strdup(prefix_end + sizeof("__") - 1);
int len = strlen(prefix_end);
int pos = sizeof("__") - 1;
char *p, *id;

if (pos >= len)
return NULL;

id = strdup(prefix_end + pos);
if (id) {
/*
* __BTF_ID__func__vfs_truncate__0
Expand Down

0 comments on commit 193a983

Please sign in to comment.