diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2002-07-07 22:13:31 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2002-07-07 22:13:31 +0000 |
commit | 2bf759cba5f24c09e450bb8fcabfd9e6e32c137d (patch) | |
tree | 5eb3a30c6207558c8f8502afac3086cde4517cb6 /key.c | |
parent | 8b2eecdf9f6769520e2601d5de58991d5810873d (diff) |
- markus@cvs.openbsd.org 2002/07/04 10:41:47
[key.c monitor_wrap.c ssh-dss.c ssh-rsa.c]
don't allocate, copy, and discard if there is not interested in the data;
ok deraadt@
Diffstat (limited to 'key.c')
-rw-r--r-- | key.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -32,7 +32,7 @@ | |||
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ | 33 | */ |
34 | #include "includes.h" | 34 | #include "includes.h" |
35 | RCSID("$OpenBSD: key.c,v 1.47 2002/07/04 04:15:33 deraadt Exp $"); | 35 | RCSID("$OpenBSD: key.c,v 1.48 2002/07/04 10:41:47 markus Exp $"); |
36 | 36 | ||
37 | #include <openssl/evp.h> | 37 | #include <openssl/evp.h> |
38 | 38 | ||
@@ -729,7 +729,6 @@ key_to_blob(Key *key, u_char **blobp, u_int *lenp) | |||
729 | { | 729 | { |
730 | Buffer b; | 730 | Buffer b; |
731 | int len; | 731 | int len; |
732 | u_char *buf; | ||
733 | 732 | ||
734 | if (key == NULL) { | 733 | if (key == NULL) { |
735 | error("key_to_blob: key == NULL"); | 734 | error("key_to_blob: key == NULL"); |
@@ -755,16 +754,14 @@ key_to_blob(Key *key, u_char **blobp, u_int *lenp) | |||
755 | return 0; | 754 | return 0; |
756 | } | 755 | } |
757 | len = buffer_len(&b); | 756 | len = buffer_len(&b); |
758 | buf = xmalloc(len); | ||
759 | memcpy(buf, buffer_ptr(&b), len); | ||
760 | memset(buffer_ptr(&b), 0, len); | ||
761 | buffer_free(&b); | ||
762 | if (lenp != NULL) | 757 | if (lenp != NULL) |
763 | *lenp = len; | 758 | *lenp = len; |
764 | if (blobp != NULL) | 759 | if (blobp != NULL) { |
765 | *blobp = buf; | 760 | *blobp = xmalloc(len); |
766 | else | 761 | memcpy(*blobp, buffer_ptr(&b), len); |
767 | xfree(buf); | 762 | } |
763 | memset(buffer_ptr(&b), 0, len); | ||
764 | buffer_free(&b); | ||
768 | return len; | 765 | return len; |
769 | } | 766 | } |
770 | 767 | ||