[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230801-nolibc-warnings-v2-9-1ba5ca57bd9b@weissschuh.net>
Date: Tue, 01 Aug 2023 07:30:16 +0200
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Willy Tarreau <w@....eu>, Shuah Khan <shuah@...nel.org>
Cc: linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
Yuan Tan <tanyuan@...ylab.org>,
Zhangjin Wu <falcon@...ylab.org>,
Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH v2 09/10] selftests/nolibc: test return value of read() in
test_vfprintf
If read() fails and returns -1 buf would be accessed out of bounds.
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
tools/testing/selftests/nolibc/nolibc-test.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 82714051c72f..a334f8450a34 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -1031,6 +1031,12 @@ static int expect_vfprintf(int llen, int c, const char *expected, const char *fm
lseek(fd, 0, SEEK_SET);
r = read(fd, buf, sizeof(buf) - 1);
+ if (r == -1) {
+ llen += printf(" read() = %s", errorname(errno));
+ result(llen, FAIL);
+ return 1;
+ }
+
buf[r] = '\0';
fclose(memfile);
--
2.41.0
Powered by blists - more mailing lists