summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authormouring <mouring>2003-09-16 03:31:03 +0000
committermouring <mouring>2003-09-16 03:31:03 +0000
commitc62d56d90a3efd3b084e79f6041e9684fd4f52fb (patch)
treeb9c900f2bac827057e4ae0f55290adefe2e0d268 /buffer.c
parent8621b105e816659d636acff7a5184750e78a78ca (diff)
downloadopenssh-c62d56d90a3efd3b084e79f6041e9684fd4f52fb.tar.gz
- deraadt@cvs.openbsd.org 2003/09/16 03:03:47
[buffer.c] do not expand buffer before attempting to reallocate it; markus ok
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/buffer.c b/buffer.c
index ad04b267..8ff8c2f4 100644
--- a/buffer.c
+++ b/buffer.c
@@ -12,7 +12,7 @@
*/
#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 "buffer.h"
@@ -69,6 +69,7 @@ buffer_append(Buffer *buffer, const void *data, u_int len)
void *
buffer_append_space(Buffer *buffer, u_int len)
{
+ u_int newlen;
void *p;
if (len > 0x100000)
@@ -98,11 +99,13 @@ restart:
goto restart;
}
/* 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",
- buffer->alloc);
- buffer->buf = xrealloc(buffer->buf, buffer->alloc);
+ newlen);
+ buffer->buf = xrealloc(buffer->buf, newlen);
+ buffer->alloc = newlen;
goto restart;
/* NOTREACHED */
}