Check for integer overflow before calling sbrk(2), since it uses a
signed increment argument, but the size is an unsigned integer.
This commit is contained in:
parent
aec0c4d822
commit
e3085308be
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178645
@ -1530,6 +1530,13 @@ static void *
|
|||||||
chunk_alloc_dss(size_t size)
|
chunk_alloc_dss(size_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sbrk() uses a signed increment argument, so take care not to
|
||||||
|
* interpret a huge allocation request as a negative increment.
|
||||||
|
*/
|
||||||
|
if ((intptr_t)size < 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
malloc_mutex_lock(&dss_mtx);
|
malloc_mutex_lock(&dss_mtx);
|
||||||
if (dss_prev != (void *)-1) {
|
if (dss_prev != (void *)-1) {
|
||||||
intptr_t incr;
|
intptr_t incr;
|
||||||
|
Loading…
Reference in New Issue
Block a user