summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/buffer.c
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2003-09-16 21:02:39 +0000
committermarkus <markus@openbsd.org>2003-09-16 21:02:39 +0000
commitd16427222f3bd2979f43dcda8f1558cb77f368e5 (patch)
treef95b16142e66ffd772b4445d61acea289be3234a /usr.bin/ssh/buffer.c
parentDo not use | !FOO to mention undesirable flags, but rather & ~FOO - hopefully (diff)
downloadwireguard-openbsd-d16427222f3bd2979f43dcda8f1558cb77f368e5.tar.xz
wireguard-openbsd-d16427222f3bd2979f43dcda8f1558cb77f368e5.zip
more malloc/fatal fixes; ok millert/deraadt; ghudson at MIT.EDU
Diffstat (limited to 'usr.bin/ssh/buffer.c')
-rw-r--r--usr.bin/ssh/buffer.c15
1 files changed, 10 insertions, 5 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);
+ }
}
/*