Commit 193a983c authored by Jiri Olsa's avatar Jiri Olsa Committed by Alexei Starovoitov
Browse files

tools resolve_btfids: Add size check to get_id function



To make sure we don't crash on malformed symbols.

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200825192124.710397-2-jolsa@kernel.org
parent 2532f849
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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