summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2003-09-26 19:15:53 +0000
committerjoe <joe@FreeBSD.org>2003-09-26 19:15:53 +0000
commitdc42ef026434942c55e8af3dd0e975d36afc6843 (patch)
treef8739ebe09332a7122569bd3e41f1574f5aaa117 /crypto
parent0689a1c0d3a7bf6f827a1f7ee07bdb8d1e3c1fb1 (diff)
downloadFreeBSD-src-dc42ef026434942c55e8af3dd0e975d36afc6843.zip
FreeBSD-src-dc42ef026434942c55e8af3dd0e975d36afc6843.tar.gz
Additional corrections to OpenSSH buffer handling.
Obtained from: openssh.org Originally committed to head by: nectar
Diffstat (limited to 'crypto')
-rw-r--r--crypto/openssh/buffer.c13
-rw-r--r--crypto/openssh/channels.c5
2 files changed, 12 insertions, 6 deletions
diff --git a/crypto/openssh/buffer.c b/crypto/openssh/buffer.c
index 8ff8c2f..9c9ca64 100644
--- a/crypto/openssh/buffer.c
+++ b/crypto/openssh/buffer.c
@@ -23,8 +23,11 @@ RCSID("$OpenBSD: buffer.c,v 1.17 2003/09/16 03:03:47 deraadt Exp $");
void
buffer_init(Buffer *buffer)
{
- buffer->alloc = 4096;
- buffer->buf = xmalloc(buffer->alloc);
+ const u_int len = 4096;
+
+ buffer->alloc = 0;
+ buffer->buf = xmalloc(len);
+ buffer->alloc = len;
buffer->offset = 0;
buffer->end = 0;
}
@@ -34,8 +37,10 @@ buffer_init(Buffer *buffer)
void
buffer_free(Buffer *buffer)
{
- memset(buffer->buf, 0, buffer->alloc);
- xfree(buffer->buf);
+ if (buffer->alloc > 0) {
+ memset(buffer->buf, 0, buffer->alloc);
+ xfree(buffer->buf);
+ }
}
/*
diff --git a/crypto/openssh/channels.c b/crypto/openssh/channels.c
index 1937b02..218744d 100644
--- a/crypto/openssh/channels.c
+++ b/crypto/openssh/channels.c
@@ -229,12 +229,13 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
if (found == -1) {
/* There are no free slots. Take last+1 slot and expand the array. */
found = channels_alloc;
- channels_alloc += 10;
if (channels_alloc > 10000)
fatal("channel_new: internal error: channels_alloc %d "
"too big.", channels_alloc);
+ channels = xrealloc(channels,
+ (channels_alloc + 10) * sizeof(Channel *));
+ channels_alloc += 10;
debug2("channel: expanding %d", channels_alloc);
- channels = xrealloc(channels, channels_alloc * sizeof(Channel *));
for (i = found; i < channels_alloc; i++)
channels[i] = NULL;
}
OpenPOWER on IntegriCloud