arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1595191-2.patch

147e83
commit 3bb748257405e94e13de76573a4e9da1cfd961d0
147e83
Author: Florian Weimer <fweimer@redhat.com>
147e83
Date:   Tue Jul 3 15:54:49 2018 +0200
147e83
147e83
    libio: Disable vtable validation in case of interposition [BZ #23313]
147e83
    
147e83
    (cherry picked from commit c402355dfa7807b8e0adb27c009135a7e2b9f1b0)
147e83
147e83
Backported from the upstream release/2.27/master branch.
147e83
147e83
diff --git a/libio/vtables.c b/libio/vtables.c
147e83
index e364ea03edbfa75b..d6478e4bab9050ce 100644
147e83
--- a/libio/vtables.c
147e83
+++ b/libio/vtables.c
147e83
@@ -68,3 +68,19 @@ _IO_vtable_check (void)
147e83
 
147e83
   __libc_fatal ("Fatal error: glibc detected an invalid stdio handle\n");
147e83
 }
147e83
+
147e83
+/* Some variants of libstdc++ interpose _IO_2_1_stdin_ etc. and
147e83
+   install their own vtables directly, without calling _IO_init or
147e83
+   other functions.  Detect this by looking at the vtables values
147e83
+   during startup, and disable vtable validation in this case.  */
147e83
+#ifdef SHARED
147e83
+__attribute__ ((constructor))
147e83
+static void
147e83
+check_stdfiles_vtables (void)
147e83
+{
147e83
+  if (_IO_2_1_stdin_.vtable != &_IO_file_jumps
147e83
+      || _IO_2_1_stdout_.vtable != &_IO_file_jumps
147e83
+      || _IO_2_1_stderr_.vtable != &_IO_file_jumps)
147e83
+    IO_set_accept_foreign_vtables (&_IO_vtable_check);
147e83
+}
147e83
+#endif