diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 1999-11-12 17:28:36 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 1999-11-12 17:28:36 +0000 |
commit | 55468227601d8ece05730ee596dc4ca93cce275b (patch) | |
tree | 76ecfd4a1543641a1bb4ad1c1cd07b1c6c0dbf20 /usr.bin/ssh/bufaux.c | |
parent | 964ff9c3a0da334054f587a2ad76fa1925fb06e6 (diff) |
save a view malloc/memcpy/memset/free's, ok niels
Diffstat (limited to 'usr.bin/ssh/bufaux.c')
-rw-r--r-- | usr.bin/ssh/bufaux.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/ssh/bufaux.c b/usr.bin/ssh/bufaux.c index 390431d1887..404b03f2b18 100644 --- a/usr.bin/ssh/bufaux.c +++ b/usr.bin/ssh/bufaux.c @@ -15,7 +15,7 @@ Buffers. */ #include "includes.h" -RCSID("$Id: bufaux.c,v 1.3 1999/11/02 19:42:35 markus Exp $"); +RCSID("$Id: bufaux.c,v 1.4 1999/11/12 17:28:35 markus Exp $"); #include "ssh.h" #include <ssl/bn.h> @@ -64,10 +64,11 @@ buffer_get_bignum(Buffer *buffer, BIGNUM *value) bits = GET_16BIT(buf); /* Compute the number of binary bytes that follow. */ bytes = (bits + 7) / 8; - bin = xmalloc(bytes); - buffer_get(buffer, bin, bytes); + if (buffer_len(buffer) < bytes) + fatal("buffer_get_bignum: input buffer too small"); + bin = buffer_ptr(buffer); BN_bin2bn(bin, bytes, value); - xfree(bin); + buffer_consume(buffer, bytes); return 2 + bytes; } |