Mail Archives: djgpp-workers/2003/04/22/08:43:47
Charles Sandmann wrote:
>
... snip ...
>
> /* Refuse ridiculously large requests right away. Anything beyond
> 2GB will be treated by sbrk as a negative request, i.e. as a
> request to _decrease_ the heap size. */
> if (size > 0x7fffffffU - 0x10000U) /* sbrk rounds up to 64KB */
> {
> if (__libc_malloc_fail_hook)
> __libc_malloc_fail_hook(size);
> return 0;
> }
>
> sbrk() takes a signed integer - so you must make sure you don't
> pass it anything too big. If someone passes a request to malloc
> for something huge, and you pass it to sbrk() - problems. It
> appears to succeed, but instead has just decreased the memory
> available (bad corruption).
>
... snip ...
>
> http://www.delorie.com/bin/cvsweb.cgi/djgpp/src/libc/ansi/stdlib/malloc.c
Took a look there, and AFAICT the large sbrk is the only thing
missing. Fixed. This means that NOTHING can create an object
larger than that (INT_MAX - safety) value, since they obviously
won't fit on the stack.
--
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
- Raw text -