[libc] remove use after free in tests.
authorMichael Jones <michaelrj@google.com>
Mon, 12 Dec 2022 21:21:41 +0000 (13:21 -0800)
committerMichael Jones <michaelrj@google.com>
Mon, 12 Dec 2022 21:22:56 +0000 (13:22 -0800)
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
libc/test/src/stdio/ftell_test.cpp

index 49af468..f473abd 100644 (file)
@@ -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<FILE *>(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<FILE *>(nullptr));
+  // EXPECT_NE(errno, 0);
 }
 
 TEST(LlvmLibcFILETest, FFlush) {
index f83a74d..97facaf 100644 (file)
@@ -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);
   }
 };