summaryrefslogtreecommitdiff
path: root/sshconnect2.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 /sshconnect2.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 'sshconnect2.c')
-rw-r--r--sshconnect2.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/sshconnect2.c b/sshconnect2.c
index f8d21489e..c3501c2a5 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -1029,8 +1029,7 @@ pubkey_prepare(Authctxt *authctxt)
1029 if (key && key->type == KEY_RSA1) 1029 if (key && key->type == KEY_RSA1)
1030 continue; 1030 continue;
1031 options.identity_keys[i] = NULL; 1031 options.identity_keys[i] = NULL;
1032 id = xmalloc(sizeof(*id)); 1032 id = xcalloc(1, sizeof(*id));
1033 memset(id, 0, sizeof(*id));
1034 id->key = key; 1033 id->key = key;
1035 id->filename = xstrdup(options.identity_files[i]); 1034 id->filename = xstrdup(options.identity_files[i]);
1036 TAILQ_INSERT_TAIL(&files, id, next); 1035 TAILQ_INSERT_TAIL(&files, id, next);
@@ -1054,8 +1053,7 @@ pubkey_prepare(Authctxt *authctxt)
1054 } 1053 }
1055 } 1054 }
1056 if (!found && !options.identities_only) { 1055 if (!found && !options.identities_only) {
1057 id = xmalloc(sizeof(*id)); 1056 id = xcalloc(1, sizeof(*id));
1058 memset(id, 0, sizeof(*id));
1059 id->key = key; 1057 id->key = key;
1060 id->filename = comment; 1058 id->filename = comment;
1061 id->ac = ac; 1059 id->ac = ac;
@@ -1336,9 +1334,7 @@ userauth_hostbased(Authctxt *authctxt)
1336 return 0; 1334 return 0;
1337 } 1335 }
1338 len = strlen(p) + 2; 1336 len = strlen(p) + 2;
1339 chost = xmalloc(len); 1337 xasprintf(&chost, "%s.", p);
1340 strlcpy(chost, p, len);
1341 strlcat(chost, ".", len);
1342 debug2("userauth_hostbased: chost %s", chost); 1338 debug2("userauth_hostbased: chost %s", chost);
1343 xfree(p); 1339 xfree(p);
1344 1340