diff options
| author | H.J. Lu <hjl.tools@gmail.com> | 2024-09-07 08:32:32 -0700 |
|---|---|---|
| committer | H.J. Lu <hjl.tools@gmail.com> | 2024-10-01 07:31:25 +0800 |
| commit | 9dfea3de7f690bff70e3c6eb346b9ad082bb2e35 (patch) | |
| tree | a49afb7e040976036fcde8ee50c76703b504a554 /libio/oldfileops.c | |
| parent | 97aa92263a151d12286d27d327edc35475fe521c (diff) | |
| download | glibc-9dfea3de7f690bff70e3c6eb346b9ad082bb2e35.tar.xz glibc-9dfea3de7f690bff70e3c6eb346b9ad082bb2e35.zip | |
libio: Set _vtable_offset before calling _IO_link_in [BZ #32148]
Since _IO_vtable_offset is used to detect the old binaries, set it
in _IO_old_file_init_internal before calling _IO_link_in which checks
_IO_vtable_offset. Add a glibc 2.0 test with copy relocation on
_IO_stderr_@GLIBC_2.0 to verify that fopen won't cause memory corruption.
This fixes BZ #32148.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Diffstat (limited to 'libio/oldfileops.c')
| -rw-r--r-- | libio/oldfileops.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libio/oldfileops.c b/libio/oldfileops.c index 97148dba9b..8f775c9094 100644 --- a/libio/oldfileops.c +++ b/libio/oldfileops.c @@ -103,9 +103,11 @@ _IO_old_file_init_internal (struct _IO_FILE_plus *fp) fp->file._old_offset = _IO_pos_BAD; fp->file._flags |= CLOSED_FILEBUF_FLAGS; - _IO_link_in (fp); + /* NB: _vtable_offset must be set before calling _IO_link_in since + _IO_vtable_offset is used to detect the old binaries. */ fp->file._vtable_offset = ((int) sizeof (struct _IO_FILE) - (int) sizeof (struct _IO_FILE_complete)); + _IO_link_in (fp); fp->file._fileno = -1; if (&_IO_stdin_used != NULL || !_IO_legacy_file ((FILE *) fp)) |
