From: Florian Weimer Date: Wed, 20 Jun 2018 07:45:19 +0000 (+0200) Subject: libio: Avoid ptrdiff_t overflow in IO_validate_vtable X-Git-Tag: glibc-2.28~180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d1c89a5d7c872a1109768f50e2508cf9a4b0348;p=thirdparty%2Fglibc.git 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. --- diff --git a/ChangeLog b/ChangeLog index 90b65fd3a67..672fbd3fd51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2018-06-20 Florian Weimer + + * libio/libioP.h (IO_validate_vtable): Avoid ptrdiff_t overflow. + 2018-06-19 Joseph Myers [BZ #23280] diff --git a/libio/libioP.h b/libio/libioP.h index 8afe7032e3f..df2633d8581 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -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. */