diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | key.c | 17 | ||||
-rw-r--r-- | monitor_wrap.c | 17 | ||||
-rw-r--r-- | ssh-dss.c | 26 | ||||
-rw-r--r-- | ssh-rsa.c | 18 |
5 files changed, 38 insertions, 46 deletions
@@ -12,6 +12,10 @@ | |||
12 | - deraadt@cvs.openbsd.org 2002/07/04 08:12:15 | 12 | - deraadt@cvs.openbsd.org 2002/07/04 08:12:15 |
13 | [channels.c packet.c] | 13 | [channels.c packet.c] |
14 | blah blah minor nothing as i read and re-read and re-read... | 14 | blah blah minor nothing as i read and re-read and re-read... |
15 | - markus@cvs.openbsd.org 2002/07/04 10:41:47 | ||
16 | [key.c monitor_wrap.c ssh-dss.c ssh-rsa.c] | ||
17 | don't allocate, copy, and discard if there is not interested in the data; | ||
18 | ok deraadt@ | ||
15 | 19 | ||
16 | 20020705 | 20 | 20020705 |
17 | - (tim) [configure.ac] AIX 4.2.1 has authenticate() in libs. | 21 | - (tim) [configure.ac] AIX 4.2.1 has authenticate() in libs. |
@@ -1295,4 +1299,4 @@ | |||
1295 | - (stevesk) entropy.c: typo in debug message | 1299 | - (stevesk) entropy.c: typo in debug message |
1296 | - (djm) ssh-keygen -i needs seeded RNG; report from markus@ | 1300 | - (djm) ssh-keygen -i needs seeded RNG; report from markus@ |
1297 | 1301 | ||
1298 | $Id: ChangeLog,v 1.2343 2002/07/07 22:11:51 mouring Exp $ | 1302 | $Id: ChangeLog,v 1.2344 2002/07/07 22:13:31 mouring Exp $ |
@@ -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 | ||
diff --git a/monitor_wrap.c b/monitor_wrap.c index 1719f89d2..78be2915f 100644 --- a/monitor_wrap.c +++ b/monitor_wrap.c | |||
@@ -25,7 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "includes.h" | 27 | #include "includes.h" |
28 | RCSID("$OpenBSD: monitor_wrap.c,v 1.15 2002/07/04 04:15:33 deraadt Exp $"); | 28 | RCSID("$OpenBSD: monitor_wrap.c,v 1.16 2002/07/04 10:41:47 markus Exp $"); |
29 | 29 | ||
30 | #include <openssl/bn.h> | 30 | #include <openssl/bn.h> |
31 | #include <openssl/dh.h> | 31 | #include <openssl/dh.h> |
@@ -446,7 +446,6 @@ mm_newkeys_to_blob(int mode, u_char **blobp, u_int *lenp) | |||
446 | { | 446 | { |
447 | Buffer b; | 447 | Buffer b; |
448 | int len; | 448 | int len; |
449 | u_char *buf; | ||
450 | Enc *enc; | 449 | Enc *enc; |
451 | Mac *mac; | 450 | Mac *mac; |
452 | Comp *comp; | 451 | Comp *comp; |
@@ -484,16 +483,14 @@ mm_newkeys_to_blob(int mode, u_char **blobp, u_int *lenp) | |||
484 | buffer_put_cstring(&b, comp->name); | 483 | buffer_put_cstring(&b, comp->name); |
485 | 484 | ||
486 | len = buffer_len(&b); | 485 | len = buffer_len(&b); |
487 | buf = xmalloc(len); | ||
488 | memcpy(buf, buffer_ptr(&b), len); | ||
489 | memset(buffer_ptr(&b), 0, len); | ||
490 | buffer_free(&b); | ||
491 | if (lenp != NULL) | 486 | if (lenp != NULL) |
492 | *lenp = len; | 487 | *lenp = len; |
493 | if (blobp != NULL) | 488 | if (blobp != NULL) { |
494 | *blobp = buf; | 489 | *blobp = xmalloc(len); |
495 | else | 490 | memcpy(*blobp, buffer_ptr(&b), len); |
496 | xfree(blobp); | 491 | } |
492 | memset(buffer_ptr(&b), 0, len); | ||
493 | buffer_free(&b); | ||
497 | return len; | 494 | return len; |
498 | } | 495 | } |
499 | 496 | ||
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: ssh-dss.c,v 1.16 2002/07/04 04:15:33 deraadt Exp $"); | 26 | RCSID("$OpenBSD: ssh-dss.c,v 1.17 2002/07/04 10:41:47 markus Exp $"); |
27 | 27 | ||
28 | #include <openssl/bn.h> | 28 | #include <openssl/bn.h> |
29 | #include <openssl/evp.h> | 29 | #include <openssl/evp.h> |
@@ -46,7 +46,7 @@ ssh_dss_sign(Key *key, u_char **sigp, u_int *lenp, | |||
46 | DSA_SIG *sig; | 46 | DSA_SIG *sig; |
47 | const EVP_MD *evp_md = EVP_sha1(); | 47 | const EVP_MD *evp_md = EVP_sha1(); |
48 | EVP_MD_CTX md; | 48 | EVP_MD_CTX md; |
49 | u_char *ret, digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN]; | 49 | u_char digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN]; |
50 | u_int rlen, slen, len, dlen; | 50 | u_int rlen, slen, len, dlen; |
51 | Buffer b; | 51 | Buffer b; |
52 | 52 | ||
@@ -79,29 +79,25 @@ ssh_dss_sign(Key *key, u_char **sigp, u_int *lenp, | |||
79 | DSA_SIG_free(sig); | 79 | DSA_SIG_free(sig); |
80 | 80 | ||
81 | if (datafellows & SSH_BUG_SIGBLOB) { | 81 | if (datafellows & SSH_BUG_SIGBLOB) { |
82 | ret = xmalloc(SIGBLOB_LEN); | ||
83 | memcpy(ret, sigblob, SIGBLOB_LEN); | ||
84 | if (lenp != NULL) | 82 | if (lenp != NULL) |
85 | *lenp = SIGBLOB_LEN; | 83 | *lenp = SIGBLOB_LEN; |
86 | if (sigp != NULL) | 84 | if (sigp != NULL) { |
87 | *sigp = ret; | 85 | *sigp = xmalloc(SIGBLOB_LEN); |
88 | else | 86 | memcpy(*sigp, sigblob, SIGBLOB_LEN); |
89 | xfree(ret); | 87 | } |
90 | } else { | 88 | } else { |
91 | /* ietf-drafts */ | 89 | /* ietf-drafts */ |
92 | buffer_init(&b); | 90 | buffer_init(&b); |
93 | buffer_put_cstring(&b, "ssh-dss"); | 91 | buffer_put_cstring(&b, "ssh-dss"); |
94 | buffer_put_string(&b, sigblob, SIGBLOB_LEN); | 92 | buffer_put_string(&b, sigblob, SIGBLOB_LEN); |
95 | len = buffer_len(&b); | 93 | len = buffer_len(&b); |
96 | ret = xmalloc(len); | ||
97 | memcpy(ret, buffer_ptr(&b), len); | ||
98 | buffer_free(&b); | ||
99 | if (lenp != NULL) | 94 | if (lenp != NULL) |
100 | *lenp = len; | 95 | *lenp = len; |
101 | if (sigp != NULL) | 96 | if (sigp != NULL) { |
102 | *sigp = ret; | 97 | *sigp = xmalloc(len); |
103 | else | 98 | memcpy(*sigp, buffer_ptr(&b), len); |
104 | xfree(ret); | 99 | } |
100 | buffer_free(&b); | ||
105 | } | 101 | } |
106 | return 0; | 102 | return 0; |
107 | } | 103 | } |
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: ssh-rsa.c,v 1.22 2002/07/04 04:15:33 deraadt Exp $"); | 26 | RCSID("$OpenBSD: ssh-rsa.c,v 1.23 2002/07/04 10:41:47 markus Exp $"); |
27 | 27 | ||
28 | #include <openssl/evp.h> | 28 | #include <openssl/evp.h> |
29 | #include <openssl/err.h> | 29 | #include <openssl/err.h> |
@@ -44,7 +44,7 @@ ssh_rsa_sign(Key *key, u_char **sigp, u_int *lenp, | |||
44 | { | 44 | { |
45 | const EVP_MD *evp_md; | 45 | const EVP_MD *evp_md; |
46 | EVP_MD_CTX md; | 46 | EVP_MD_CTX md; |
47 | u_char digest[EVP_MAX_MD_SIZE], *sig, *ret; | 47 | u_char digest[EVP_MAX_MD_SIZE], *sig; |
48 | u_int slen, dlen, len; | 48 | u_int slen, dlen, len; |
49 | int ok, nid; | 49 | int ok, nid; |
50 | Buffer b; | 50 | Buffer b; |
@@ -90,18 +90,16 @@ ssh_rsa_sign(Key *key, u_char **sigp, u_int *lenp, | |||
90 | buffer_put_cstring(&b, "ssh-rsa"); | 90 | buffer_put_cstring(&b, "ssh-rsa"); |
91 | buffer_put_string(&b, sig, slen); | 91 | buffer_put_string(&b, sig, slen); |
92 | len = buffer_len(&b); | 92 | len = buffer_len(&b); |
93 | ret = xmalloc(len); | 93 | if (lenp != NULL) |
94 | memcpy(ret, buffer_ptr(&b), len); | 94 | *lenp = len; |
95 | if (sigp != NULL) { | ||
96 | *sigp = xmalloc(len); | ||
97 | memcpy(*sigp, buffer_ptr(&b), len); | ||
98 | } | ||
95 | buffer_free(&b); | 99 | buffer_free(&b); |
96 | memset(sig, 's', slen); | 100 | memset(sig, 's', slen); |
97 | xfree(sig); | 101 | xfree(sig); |
98 | 102 | ||
99 | if (lenp != NULL) | ||
100 | *lenp = len; | ||
101 | if (sigp != NULL) | ||
102 | *sigp = ret; | ||
103 | else | ||
104 | xfree(ret); | ||
105 | return 0; | 103 | return 0; |
106 | } | 104 | } |
107 | 105 | ||