diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2002-07-08 00:13:31 +0200 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2002-07-08 00:13:31 +0200 |
commit | 2bf759cba5f24c09e450bb8fcabfd9e6e32c137d (patch) | |
tree | 5eb3a30c6207558c8f8502afac3086cde4517cb6 /ssh-dss.c | |
parent | - deraadt@cvs.openbsd.org 2002/07/04 08:12:15 (diff) | |
download | openssh-2bf759cba5f24c09e450bb8fcabfd9e6e32c137d.tar.xz openssh-2bf759cba5f24c09e450bb8fcabfd9e6e32c137d.zip |
- 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 'ssh-dss.c')
-rw-r--r-- | ssh-dss.c | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-dss.c,v 1.16 2002/07/04 04:15:33 deraadt Exp $"); +RCSID("$OpenBSD: ssh-dss.c,v 1.17 2002/07/04 10:41:47 markus Exp $"); #include <openssl/bn.h> #include <openssl/evp.h> @@ -46,7 +46,7 @@ ssh_dss_sign(Key *key, u_char **sigp, u_int *lenp, DSA_SIG *sig; const EVP_MD *evp_md = EVP_sha1(); EVP_MD_CTX md; - u_char *ret, digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN]; + u_char digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN]; u_int rlen, slen, len, dlen; Buffer b; @@ -79,29 +79,25 @@ ssh_dss_sign(Key *key, u_char **sigp, u_int *lenp, DSA_SIG_free(sig); if (datafellows & SSH_BUG_SIGBLOB) { - ret = xmalloc(SIGBLOB_LEN); - memcpy(ret, sigblob, SIGBLOB_LEN); if (lenp != NULL) *lenp = SIGBLOB_LEN; - if (sigp != NULL) - *sigp = ret; - else - xfree(ret); + if (sigp != NULL) { + *sigp = xmalloc(SIGBLOB_LEN); + memcpy(*sigp, sigblob, SIGBLOB_LEN); + } } else { /* ietf-drafts */ buffer_init(&b); buffer_put_cstring(&b, "ssh-dss"); buffer_put_string(&b, sigblob, SIGBLOB_LEN); len = buffer_len(&b); - ret = xmalloc(len); - memcpy(ret, buffer_ptr(&b), len); - buffer_free(&b); if (lenp != NULL) *lenp = len; - if (sigp != NULL) - *sigp = ret; - else - xfree(ret); + if (sigp != NULL) { + *sigp = xmalloc(len); + memcpy(*sigp, buffer_ptr(&b), len); + } + buffer_free(&b); } return 0; } |