summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2003-09-16 21:02:41 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2003-09-16 21:02:41 +0000
commit0c0a9ebda7c535bddc73e803937aca99bc88393d (patch)
treeca63f88cce2e529d4b590b4b441c2ffb0f853faf /usr.bin
parent6d588810256755cc4fdc46448292d1fb9b79ebc2 (diff)
more malloc/fatal fixes; ok millert/deraadt; ghudson at MIT.EDU
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/buffer.c15
-rw-r--r--usr.bin/ssh/channels.c7
-rw-r--r--usr.bin/ssh/version.h4
3 files changed, 16 insertions, 10 deletions
diff --git a/usr.bin/ssh/buffer.c b/usr.bin/ssh/buffer.c
index 8ff8c2f48b4..aee293f8bd4 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.17 2003/09/16 03:03:47 deraadt Exp $");
+RCSID("$OpenBSD: buffer.c,v 1.18 2003/09/16 21:02:39 markus Exp $");
#include "xmalloc.h"
#include "buffer.h"
@@ -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/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c
index 272d67c846a..a6865404509 100644
--- a/usr.bin/ssh/channels.c
+++ b/usr.bin/ssh/channels.c
@@ -39,7 +39,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: channels.c,v 1.194 2003/08/29 10:04:36 markus Exp $");
+RCSID("$OpenBSD: channels.c,v 1.195 2003/09/16 21:02:40 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -228,12 +228,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;
}
diff --git a/usr.bin/ssh/version.h b/usr.bin/ssh/version.h
index 8c4f162454d..eb1a639114e 100644
--- a/usr.bin/ssh/version.h
+++ b/usr.bin/ssh/version.h
@@ -1,3 +1,3 @@
-/* $OpenBSD: version.h,v 1.38 2003/09/02 16:40:29 markus Exp $ */
+/* $OpenBSD: version.h,v 1.39 2003/09/16 21:02:40 markus Exp $ */
-#define SSH_VERSION "OpenSSH_3.7"
+#define SSH_VERSION "OpenSSH_3.7.1"