selftests/nolibc: prevent out of bounds access in expect_vfprintf
authorThomas Weißschuh <linux@weissschuh.net>
Thu, 3 Aug 2023 07:28:56 +0000 (09:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Aug 2023 03:17:07 +0000 (05:17 +0200)
commit9c5e490093e83e165022e0311bd7df5aa06cc860
tree91fea461e88eec1e8eb94c6a58cebfe70e84697e
parent37266a9ec7f5a3144c2070baeea2628c30ef07e5
selftests/nolibc: prevent out of bounds access in expect_vfprintf

If read() fails and returns -1 (or returns garbage for some other
reason) buf would be accessed out of bounds.
Only use the return value of read() after it has been validated.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
tools/testing/selftests/nolibc/nolibc-test.c