summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/ssh.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2006-03-25 00:05:40 +0000
committerdjm <djm@openbsd.org>2006-03-25 00:05:40 +0000
commitf846f1e36b1b1e10541c6b59635584eae5734f55 (patch)
tree2586060455068676ade98385f9252325c62f52a3 /usr.bin/ssh/ssh.c
parentoops, chip misnamed; roman.hunt@comcast.net (diff)
downloadwireguard-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/ssh.c')
-rw-r--r--usr.bin/ssh/ssh.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index e0838d9bb0a..4be85c6f4a0 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -672,7 +672,7 @@ main(int ac, char **av)
if (options.rhosts_rsa_authentication ||
options.hostbased_authentication) {
sensitive_data.nkeys = 3;
- sensitive_data.keys = xmalloc(sensitive_data.nkeys *
+ sensitive_data.keys = xcalloc(sensitive_data.nkeys,
sizeof(Key));
PRIV_START;
@@ -1229,7 +1229,8 @@ env_permitted(char *env)
int i;
char name[1024], *cp;
- strlcpy(name, env, sizeof(name));
+ if (strlcpy(name, env, sizeof(name)) >= sizeof(name))
+ fatal("env_permitted: name too long");
if ((cp = strchr(name, '=')) == NULL)
return (0);