mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
libio: Avoid ptrdiff_t overflow in IO_validate_vtable
If the candidate pointer is sufficiently far away from __start___libc_IO_vtables, the result might not fit into ptrdiff_t.
This commit is contained in:
@ -830,8 +830,8 @@ IO_validate_vtable (const struct _IO_jump_t *vtable)
|
||||
/* Fast path: The vtable pointer is within the __libc_IO_vtables
|
||||
section. */
|
||||
uintptr_t section_length = __stop___libc_IO_vtables - __start___libc_IO_vtables;
|
||||
const char *ptr = (const char *) vtable;
|
||||
uintptr_t offset = ptr - __start___libc_IO_vtables;
|
||||
uintptr_t ptr = (uintptr_t) vtable;
|
||||
uintptr_t offset = ptr - (uintptr_t) __start___libc_IO_vtables;
|
||||
if (__glibc_unlikely (offset >= section_length))
|
||||
/* The vtable pointer is not in the expected section. Use the
|
||||
slow path, which will terminate the process if necessary. */
|
||||
|
Reference in New Issue
Block a user