bpf: btf: Fix vsnprintf return value check
Bugzilla: https://bugzilla.redhat.com/2137876 commit 58250ae350de8d28ce91ade4605d32c9e7f062a8 Author: Fedor Tokarev <ftokarev@gmail.com> Date: Mon Jul 11 23:13:17 2022 +0200 bpf: btf: Fix vsnprintf return value check vsnprintf returns the number of characters which would have been written if enough space had been available, excluding the terminating null byte. Thus, the return value of 'len_left' means that the last character has been dropped. Signed-off-by: Fedor Tokarev <ftokarev@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Alan Maguire <alan.maguire@oracle.com> Link: https://lore.kernel.org/bpf/20220711211317.GA1143610@laptop Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
parent
ee0991e7ce
commit
cb6acbdffd
|
@ -6643,7 +6643,7 @@ static void btf_snprintf_show(struct btf_show *show, const char *fmt,
|
|||
if (len < 0) {
|
||||
ssnprintf->len_left = 0;
|
||||
ssnprintf->len = len;
|
||||
} else if (len > ssnprintf->len_left) {
|
||||
} else if (len >= ssnprintf->len_left) {
|
||||
/* no space, drive on to get length we would have written */
|
||||
ssnprintf->len_left = 0;
|
||||
ssnprintf->len += len;
|
||||
|
|
Loading…
Reference in New Issue