Skip to content

Commit a8f1257

Browse files
tititiou36Alexei Starovoitov
authored andcommitted
bpf: Fix a erroneous check after snprintf()
snprintf() does not return negative error code on error, it returns the number of characters which *would* be generated for the given input. Fix the error handling check. Fixes: 57539b1 ("bpf: Enable annotating trusted nested pointers") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/393bdebc87b22563c08ace094defa7160eb7a6c0.1694190795.git.christophe.jaillet@wanadoo.fr Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 4eb94a7 commit a8f1257

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/bpf/btf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8501,7 +8501,7 @@ bool btf_nested_type_is_trusted(struct bpf_verifier_log *log,
85018501
tname = btf_name_by_offset(btf, walk_type->name_off);
85028502

85038503
ret = snprintf(safe_tname, sizeof(safe_tname), "%s%s", tname, suffix);
8504-
if (ret < 0)
8504+
if (ret >= sizeof(safe_tname))
85058505
return false;
85068506

85078507
safe_id = btf_find_by_name_kind(btf, safe_tname, BTF_INFO_KIND(walk_type->info));

0 commit comments

Comments
 (0)