diff options
author | Florian Weimer <fweimer@redhat.com> | 2018-06-26 10:24:52 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2018-06-26 10:24:52 +0200 |
commit | c402355dfa7807b8e0adb27c009135a7e2b9f1b0 (patch) | |
tree | 24a50fd3ad75c969ed22e0c456f33ee75a6bd922 /libio/vtables.c | |
parent | 43b1048ab9418e902aac8c834a7a9a88c501620a (diff) | |
download | glibc-c402355dfa7807b8e0adb27c009135a7e2b9f1b0.tar glibc-c402355dfa7807b8e0adb27c009135a7e2b9f1b0.tar.gz glibc-c402355dfa7807b8e0adb27c009135a7e2b9f1b0.tar.bz2 glibc-c402355dfa7807b8e0adb27c009135a7e2b9f1b0.zip |
libio: Disable vtable validation in case of interposition [BZ #23313]
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 9fd4ccf642..9df75668c8 100644 --- a/libio/vtables.c +++ b/libio/vtables.c @@ -71,3 +71,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 |