summaryrefslogtreecommitdiffstats
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 91081b18..030df6be 100644
--- a/kex.c
+++ b/kex.c
@@ -82,7 +82,7 @@ kex_buf2prop(Buffer *raw, int *first_kex_follows)
int i;
char **proposal;
- proposal = xmalloc(PROPOSAL_MAX * sizeof(char *));
+ proposal = xcalloc(PROPOSAL_MAX, sizeof(char *));
buffer_init(&b);
buffer_append(&b, buffer_ptr(raw), buffer_len(raw));
@@ -217,8 +217,7 @@ kex_setup(char *proposal[PROPOSAL_MAX])
{
Kex *kex;
- kex = xmalloc(sizeof(*kex));
- memset(kex, 0, sizeof(*kex));
+ kex = xcalloc(1, sizeof(*kex));
buffer_init(&kex->peer);
buffer_init(&kex->my);
kex_prop2buf(&kex->my, proposal);
@@ -379,8 +378,7 @@ kex_choose_conf(Kex *kex)
/* Algorithm Negotiation */
for (mode = 0; mode < MODE_MAX; mode++) {
- newkeys = xmalloc(sizeof(*newkeys));
- memset(newkeys, 0, sizeof(*newkeys));
+ newkeys = xcalloc(1, sizeof(*newkeys));
kex->newkeys[mode] = newkeys;
ctos = (!kex->server && mode == MODE_OUT) || (kex->server && mode == MODE_IN);
nenc = ctos ? PROPOSAL_ENC_ALGS_CTOS : PROPOSAL_ENC_ALGS_STOC;