summaryrefslogtreecommitdiff
path: root/kex.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-03-26 14:19:21 +1100
committerDamien Miller <djm@mindrot.org>2006-03-26 14:19:21 +1100
commit07d86bec5eeaf19fe33dca99c8ebcbe9a77c3938 (patch)
tree098295eee2d7ec7b116b0db3ac4b580713dd5ab0 /kex.c
parent7cd4579eb3c5afd22ae24436fd2611cd3aa0150a (diff)
- djm@cvs.openbsd.org 2006/03/25 00:05:41
[auth-bsdauth.c auth-skey.c auth.c auth2-chall.c channels.c] [clientloop.c deattack.c gss-genr.c kex.c key.c misc.c moduli.c] [monitor.c monitor_wrap.c packet.c scard.c sftp-server.c ssh-agent.c] [ssh-keyscan.c ssh.c sshconnect.c sshconnect2.c sshd.c uuencode.c] [xmalloc.c xmalloc.h] introduce xcalloc() and xasprintf() failure-checked allocations functions and use them throughout openssh xcalloc is particularly important because malloc(nmemb * size) is a dangerous idiom (subject to integer overflow) and it is time for it to die feedback and ok deraadt@
Diffstat (limited to 'kex.c')
-rw-r--r--kex.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/kex.c b/kex.c
index 91081b18e..030df6be0 100644
--- a/kex.c
+++ b/kex.c
@@ -82,7 +82,7 @@ kex_buf2prop(Buffer *raw, int *first_kex_follows)
82 int i; 82 int i;
83 char **proposal; 83 char **proposal;
84 84
85 proposal = xmalloc(PROPOSAL_MAX * sizeof(char *)); 85 proposal = xcalloc(PROPOSAL_MAX, sizeof(char *));
86 86
87 buffer_init(&b); 87 buffer_init(&b);
88 buffer_append(&b, buffer_ptr(raw), buffer_len(raw)); 88 buffer_append(&b, buffer_ptr(raw), buffer_len(raw));
@@ -217,8 +217,7 @@ kex_setup(char *proposal[PROPOSAL_MAX])
217{ 217{
218 Kex *kex; 218 Kex *kex;
219 219
220 kex = xmalloc(sizeof(*kex)); 220 kex = xcalloc(1, sizeof(*kex));
221 memset(kex, 0, sizeof(*kex));
222 buffer_init(&kex->peer); 221 buffer_init(&kex->peer);
223 buffer_init(&kex->my); 222 buffer_init(&kex->my);
224 kex_prop2buf(&kex->my, proposal); 223 kex_prop2buf(&kex->my, proposal);
@@ -379,8 +378,7 @@ kex_choose_conf(Kex *kex)
379 378
380 /* Algorithm Negotiation */ 379 /* Algorithm Negotiation */
381 for (mode = 0; mode < MODE_MAX; mode++) { 380 for (mode = 0; mode < MODE_MAX; mode++) {
382 newkeys = xmalloc(sizeof(*newkeys)); 381 newkeys = xcalloc(1, sizeof(*newkeys));
383 memset(newkeys, 0, sizeof(*newkeys));
384 kex->newkeys[mode] = newkeys; 382 kex->newkeys[mode] = newkeys;
385 ctos = (!kex->server && mode == MODE_OUT) || (kex->server && mode == MODE_IN); 383 ctos = (!kex->server && mode == MODE_OUT) || (kex->server && mode == MODE_IN);
386 nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC; 384 nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC;