diff options
author | Florian Weimer <fweimer@redhat.com> | 2018-06-26 10:24:52 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2019-11-28 16:22:07 +0100 |
commit | 1154cb63e725a579def2d7ba8383fd950931342b (patch) | |
tree | 8d5f08d40beedb662827feff679fef9a7f1b08e1 /libio/vtables.c | |
parent | a7b9e4cb8ec069a4030b081ed7c40a65e0825f47 (diff) | |
download | glibc-1154cb63e725a579def2d7ba8383fd950931342b.tar.gz glibc-1154cb63e725a579def2d7ba8383fd950931342b.tar.xz glibc-1154cb63e725a579def2d7ba8383fd950931342b.zip |
libio: Disable vtable validation in case of interposition [BZ #23313]
(cherry picked from commit c402355dfa7807b8e0adb27c009135a7e2b9f1b0)
Diffstat (limited to 'libio/vtables.c')
-rw-r--r-- | libio/vtables.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libio/vtables.c b/libio/vtables.c index b361f44e91..722a090790 100644 --- a/libio/vtables.c +++ b/libio/vtables.c @@ -70,3 +70,19 @@ _IO_vtable_check (void) __libc_fatal ("Fatal error: glibc detected an invalid stdio handle\n"); } + +/* Some variants of libstdc++ interpose _IO_2_1_stdin_ etc. and + install their own vtables directly, without calling _IO_init or + other functions. Detect this by looking at the vtables values + during startup, and disable vtable validation in this case. */ +#ifdef SHARED +__attribute__ ((constructor)) +static void +check_stdfiles_vtables (void) +{ + if (_IO_2_1_stdin_.vtable != &_IO_file_jumps + || _IO_2_1_stdout_.vtable != &_IO_file_jumps + || _IO_2_1_stderr_.vtable != &_IO_file_jumps) + IO_set_accept_foreign_vtables (&_IO_vtable_check); +} +#endif |