diff options
author | 2006-03-25 00:05:40 +0000 | |
---|---|---|
committer | 2006-03-25 00:05:40 +0000 | |
commit | f846f1e36b1b1e10541c6b59635584eae5734f55 (patch) | |
tree | 2586060455068676ade98385f9252325c62f52a3 /usr.bin/ssh/sshconnect2.c | |
parent | oops, chip misnamed; roman.hunt@comcast.net (diff) | |
download | wireguard-openbsd-f846f1e36b1b1e10541c6b59635584eae5734f55.tar.xz wireguard-openbsd-f846f1e36b1b1e10541c6b59635584eae5734f55.zip |
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 'usr.bin/ssh/sshconnect2.c')
-rw-r--r-- | usr.bin/ssh/sshconnect2.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/usr.bin/ssh/sshconnect2.c b/usr.bin/ssh/sshconnect2.c index 668801cfacb..1ed72801e1f 100644 --- a/usr.bin/ssh/sshconnect2.c +++ b/usr.bin/ssh/sshconnect2.c @@ -1028,8 +1028,7 @@ pubkey_prepare(Authctxt *authctxt) if (key && key->type == KEY_RSA1) continue; options.identity_keys[i] = NULL; - id = xmalloc(sizeof(*id)); - memset(id, 0, sizeof(*id)); + id = xcalloc(1, sizeof(*id)); id->key = key; id->filename = xstrdup(options.identity_files[i]); TAILQ_INSERT_TAIL(&files, id, next); @@ -1053,8 +1052,7 @@ pubkey_prepare(Authctxt *authctxt) } } if (!found && !options.identities_only) { - id = xmalloc(sizeof(*id)); - memset(id, 0, sizeof(*id)); + id = xcalloc(1, sizeof(*id)); id->key = key; id->filename = comment; id->ac = ac; @@ -1335,9 +1333,7 @@ userauth_hostbased(Authctxt *authctxt) return 0; } len = strlen(p) + 2; - chost = xmalloc(len); - strlcpy(chost, p, len); - strlcat(chost, ".", len); + xasprintf(&chost, "%s.", p); debug2("userauth_hostbased: chost %s", chost); xfree(p); |