mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Do not record expanded size before attempting to reallocate associated
memory. Obtained from: OpenBSD
This commit is contained in:
parent
af8524a91e
commit
8947bcb756
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: buffer.c,v 1.16 2002/06/26 08:54:18 markus Exp $");
|
RCSID("$OpenBSD: buffer.c,v 1.17 2003/09/16 03:03:47 deraadt Exp $");
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
@ -69,6 +69,7 @@ buffer_append(Buffer *buffer, const void *data, u_int len)
|
|||||||
void *
|
void *
|
||||||
buffer_append_space(Buffer *buffer, u_int len)
|
buffer_append_space(Buffer *buffer, u_int len)
|
||||||
{
|
{
|
||||||
|
u_int newlen;
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if (len > 0x100000)
|
if (len > 0x100000)
|
||||||
@ -98,11 +99,13 @@ restart:
|
|||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
/* Increase the size of the buffer and retry. */
|
/* Increase the size of the buffer and retry. */
|
||||||
buffer->alloc += len + 32768;
|
|
||||||
if (buffer->alloc > 0xa00000)
|
newlen = buffer->alloc + len + 32768;
|
||||||
|
if (newlen > 0xa00000)
|
||||||
fatal("buffer_append_space: alloc %u not supported",
|
fatal("buffer_append_space: alloc %u not supported",
|
||||||
buffer->alloc);
|
newlen);
|
||||||
buffer->buf = xrealloc(buffer->buf, buffer->alloc);
|
buffer->buf = xrealloc(buffer->buf, newlen);
|
||||||
|
buffer->alloc = newlen;
|
||||||
goto restart;
|
goto restart;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user