mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-27 03:41:23 +08:00
2e0bbbfbf9
The reallocarray function is an extension from OpenBSD. It is an integer-overflow-safe replacement for realloc(p, X*Y) and malloc(X*Y) (realloc(NULL, X*Y)). It can therefore help in preventing certain security issues in code. This is an updated version of a patch originally submitted by Rüdiger Sonderfeld in May 2014 [1]. Checked on i686-linux-gnu and x86_64-linux-gnu. [1] <https://sourceware.org/ml/libc-alpha/2014-05/msg00481.html>. 2017-05-30 Dennis Wölfing <denniswoelfing@gmx.de> Rüdiger Sonderfeld <ruediger@c-plusplus.de> * include/stdlib.h (__libc_reallocarray): New declaration. * malloc/Makefile (routines): Add reallocarray. (tests): Add tst-reallocarray.c. * malloc/Versions: Add reallocarray and __libc_reallocarray. * malloc/malloc-internal.h (check_mul_overflow_size_t): New inline function. * malloc/malloc.h (reallocarray): New declaration. * stdlib/stdlib.h (reallocarray): Likewise. * malloc/reallocarray.c: New file. * malloc/tst-reallocarray.c: New test file. * manual/memory.texi: Document reallocarray. * sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add reallocarray. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tilepro/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
83 lines
1.7 KiB
Plaintext
83 lines
1.7 KiB
Plaintext
libc {
|
|
GLIBC_2.0 {
|
|
# global variables
|
|
_obstack;
|
|
|
|
# interface of malloc functions
|
|
__libc_calloc; __libc_free; __libc_mallinfo; __libc_malloc;
|
|
__libc_mallopt; __libc_memalign; __libc_pvalloc; __libc_realloc;
|
|
__libc_valloc;
|
|
__malloc_initialize_hook; __free_hook; __malloc_hook; __realloc_hook;
|
|
__memalign_hook; __after_morecore_hook;
|
|
__malloc_initialized; __default_morecore; __morecore;
|
|
|
|
# functions used in inline functions or macros
|
|
_obstack_allocated_p; _obstack_begin; _obstack_begin_1;
|
|
_obstack_free; _obstack_memory_used; _obstack_newchunk;
|
|
|
|
# variables in normal name space
|
|
mallwatch; obstack_alloc_failed_handler; obstack_exit_failure;
|
|
|
|
# c*
|
|
calloc; cfree;
|
|
|
|
# f*
|
|
free;
|
|
|
|
# m*
|
|
mallinfo; malloc; malloc_get_state; malloc_set_state; malloc_stats;
|
|
malloc_trim; malloc_usable_size; mallopt; memalign; mprobe; mtrace;
|
|
muntrace;
|
|
|
|
# o*
|
|
obstack_free;
|
|
|
|
# p*
|
|
pvalloc;
|
|
|
|
# r*
|
|
realloc;
|
|
|
|
# t*
|
|
tr_break;
|
|
|
|
# v*
|
|
valloc;
|
|
}
|
|
GLIBC_2.1 {
|
|
# Special functions.
|
|
__libc_freeres;
|
|
}
|
|
GLIBC_2.2 {
|
|
# m*
|
|
mcheck_check_all; mcheck_pedantic;
|
|
|
|
# p*
|
|
posix_memalign;
|
|
}
|
|
GLIBC_2.10 {
|
|
malloc_info;
|
|
}
|
|
GLIBC_2.16 {
|
|
aligned_alloc;
|
|
}
|
|
GLIBC_2.26 {
|
|
reallocarray;
|
|
}
|
|
GLIBC_PRIVATE {
|
|
# Internal startup hook for libpthread.
|
|
__libc_malloc_pthread_startup;
|
|
|
|
# Internal destructor hook for libpthread.
|
|
__libc_thread_freeres;
|
|
|
|
# struct scratch_buffer support
|
|
__libc_scratch_buffer_grow;
|
|
__libc_scratch_buffer_grow_preserve;
|
|
__libc_scratch_buffer_set_array_size;
|
|
|
|
# Internal name for reallocarray
|
|
__libc_reallocarray;
|
|
}
|
|
}
|