4c174f
commit 2d1c89a5d7c872a1109768f50e2508cf9a4b0348
4c174f
Author: Florian Weimer <fweimer@redhat.com>
4c174f
Date:   Wed Jun 20 09:45:19 2018 +0200
4c174f
4c174f
    libio: Avoid ptrdiff_t overflow in IO_validate_vtable
978e96
    
4c174f
    If the candidate pointer is sufficiently far away from
4c174f
    __start___libc_IO_vtables, the result might not fit into ptrdiff_t.
4c174f
4c174f
diff --git a/libio/libioP.h b/libio/libioP.h
4c174f
index b60244ac5fc3d908..f1576381500ffc85 100644
4c174f
--- a/libio/libioP.h
4c174f
+++ b/libio/libioP.h
4c174f
@@ -957,8 +957,8 @@ IO_validate_vtable (const struct _IO_jump_t *vtable)
4c174f
   /* Fast path: The vtable pointer is within the __libc_IO_vtables
4c174f
      section.  */
4c174f
   uintptr_t section_length = __stop___libc_IO_vtables - __start___libc_IO_vtables;
4c174f
-  const char *ptr = (const char *) vtable;
4c174f
-  uintptr_t offset = ptr - __start___libc_IO_vtables;
4c174f
+  uintptr_t ptr = (uintptr_t) vtable;
4c174f
+  uintptr_t offset = ptr - (uintptr_t) __start___libc_IO_vtables;
4c174f
   if (__glibc_unlikely (offset >= section_length))
4c174f
     /* The vtable pointer is not in the expected section.  Use the
4c174f
        slow path, which will terminate the process if necessary.  */