PATCH: BPs in malloc.c
Greg McGary
greg@mcgary.org
Fri Jul 28 16:13:00 GMT 2000
Wolfram Gloger <wmglo@dent.med.uni-muenchen.de> writes:
> Looks fine to me, except for the bounded pointer size in
> chunk2mem_check(). I think the following additional patch is
> necessary.
> If you do runtime tests, please also do a test with MALLOC_CHECK_ set
> (to 1 or 2).
I will arrange the makefiles so that the testsuite runs malloc tests
with MALLOC_CHECK_=3. Is there any reason to test without MALLOC_CHECK_?
If not, then we'll just test once with MALLOC_CHECK_=3.
Since you haven't yet checked this in, should I do it for you?
OK with you, Uli?
> 2000-07-27 Wolfram Gloger <wg@malloc.de>
>
> * malloc/malloc.c (chunk2mem_check): Fix bounded pointer size.
> * malloc/malloc.c [! _LIBC]: Define RETURN_ADDRSS.
>
> Index: libc/malloc/malloc.c
> ===================================================================
> RCS file: /cvs/glibc/libc/malloc/malloc.c,v
> retrieving revision 1.68
> diff -u -r1.68 malloc.c
> --- malloc.c 2000/07/26 18:19:03 1.68
> +++ malloc.c 2000/07/27 08:44:08
> @@ -316,6 +316,7 @@
>
> #ifndef _LIBC
> # define __secure_getenv(Str) getenv (Str)
> +# define RETURN_ADDRESS(Ptr) __builtin_return_address (Ptr)
> #endif
>
> /* Macros for handling mutexes and thread-specific data. This is
> @@ -4381,12 +4382,12 @@
> chunk2mem_check(p, sz) mchunkptr p; size_t sz;
> #endif
> {
> - unsigned char* m_ptr = (unsigned char*)BOUNDED_N(chunk2mem(p), sz);
> + /* Available size for detector bytes. */
> + size_t asz = chunksize(p) - (chunk_is_mmapped(p) ? 2*SIZE_SZ : SIZE_SZ);
> + unsigned char* m_ptr = (unsigned char*)BOUNDED_N(chunk2mem(p), asz);
> size_t i;
>
> - for(i = chunksize(p) - (chunk_is_mmapped(p) ? 2*SIZE_SZ+1 : SIZE_SZ+1);
> - i > sz;
> - i -= 0xFF) {
> + for(i = asz-1; i > sz; i -= 0xFF) {
> if(i-sz < 0x100) {
> m_ptr[i] = (unsigned char)(i-sz);
> break;
More information about the Libc-hacker
mailing list