summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-16 03:03:48 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-16 03:03:48 +0000
commit2ed88c7fb005ce070bdb80f4bc9d517fb177da18 (patch)
treee6545da9a412a298d315823f7feeb886ad1cabee /usr.bin/ssh
parente878c4116ba8427d66b8e1610f58b9fb8cef6baa (diff)
do not expand buffer before attempting to reallocate it; markus ok
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/buffer.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/ssh/buffer.c b/usr.bin/ssh/buffer.c
index ad04b267e0d..8ff8c2f48b4 100644
--- a/usr.bin/ssh/buffer.c
+++ b/usr.bin/ssh/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 */
}