summaryrefslogtreecommitdiffstats
path: root/key.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-07-07 22:13:31 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-07-07 22:13:31 +0000
commit2bf759cba5f24c09e450bb8fcabfd9e6e32c137d (patch)
tree5eb3a30c6207558c8f8502afac3086cde4517cb6 /key.c
parent8b2eecdf9f6769520e2601d5de58991d5810873d (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.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/key.c b/key.c
index 34b36b0e..0b03e991 100644
--- a/key.c
+++ b/key.c
@@ -32,7 +32,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "includes.h"
-RCSID("$OpenBSD: key.c,v 1.47 2002/07/04 04:15:33 deraadt Exp $");
+RCSID("$OpenBSD: key.c,v 1.48 2002/07/04 10:41:47 markus Exp $");
#include <openssl/evp.h>
@@ -729,7 +729,6 @@ key_to_blob(Key *key, u_char **blobp, u_int *lenp)
{
Buffer b;
int len;
- u_char *buf;
if (key == NULL) {
error("key_to_blob: key == NULL");
@@ -755,16 +754,14 @@ key_to_blob(Key *key, u_char **blobp, u_int *lenp)
return 0;
}
len = buffer_len(&b);
- buf = xmalloc(len);
- memcpy(buf, buffer_ptr(&b), len);
- memset(buffer_ptr(&b), 0, len);
- buffer_free(&b);
if (lenp != NULL)
*lenp = len;
- if (blobp != NULL)
- *blobp = buf;
- else
- xfree(buf);
+ if (blobp != NULL) {
+ *blobp = xmalloc(len);
+ memcpy(*blobp, buffer_ptr(&b), len);
+ }
+ memset(buffer_ptr(&b), 0, len);
+ buffer_free(&b);
return len;
}