From 816b5e546c6553afd463f9630b248a17702700c9 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Mon, 12 Dec 2022 13:21:41 -0800 Subject: [PATCH] [libc] remove use after free in tests. There were some tests added that attempted to access files after they were closed to test errno behavior, this caused sanitizer issues. Those portions of the tests have been disabled. Differential Revision: https://reviews.llvm.org/D139878 --- libc/test/src/stdio/fileop_test.cpp | 24 ++++++++++++------------ libc/test/src/stdio/ftell_test.cpp | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp index 49af468..f473abd 100644 --- a/libc/test/src/stdio/fileop_test.cpp +++ b/libc/test/src/stdio/fileop_test.cpp @@ -114,18 +114,18 @@ TEST(LlvmLibcFILETest, SimpleFileOperations) { // Check that the other functions correctly set errno. - errno = 0; - ASSERT_NE(__llvm_libc::fseek(file, 0, SEEK_SET), 0); - EXPECT_NE(errno, 0); - - errno = 0; - ASSERT_NE(__llvm_libc::fclose(file), 0); - EXPECT_NE(errno, 0); - - errno = 0; - ASSERT_EQ(__llvm_libc::fopen("INVALID FILE NAME", "r"), - static_cast(nullptr)); - EXPECT_NE(errno, 0); + // errno = 0; + // ASSERT_NE(__llvm_libc::fseek(file, 0, SEEK_SET), 0); + // EXPECT_NE(errno, 0); + + // errno = 0; + // ASSERT_NE(__llvm_libc::fclose(file), 0); + // EXPECT_NE(errno, 0); + + // errno = 0; + // ASSERT_EQ(__llvm_libc::fopen("INVALID FILE NAME", "r"), + // static_cast(nullptr)); + // EXPECT_NE(errno, 0); } TEST(LlvmLibcFILETest, FFlush) { diff --git a/libc/test/src/stdio/ftell_test.cpp b/libc/test/src/stdio/ftell_test.cpp index f83a74d..97facaf 100644 --- a/libc/test/src/stdio/ftell_test.cpp +++ b/libc/test/src/stdio/ftell_test.cpp @@ -55,9 +55,9 @@ protected: ASSERT_EQ(0, __llvm_libc::fclose(file)); - errno = 0; - ASSERT_EQ(__llvm_libc::ftell(file), long(-1)); - ASSERT_NE(errno, 0); + // errno = 0; + // ASSERT_EQ(__llvm_libc::ftell(file), long(-1)); + // ASSERT_NE(errno, 0); } }; -- 2.7.4