diff options
author | 2009-07-02 02:11:47 +0000 | |
---|---|---|
committer | 2009-07-02 02:11:47 +0000 | |
commit | af426ca7faf8a8b04e8a69c4940b084d6b821867 (patch) | |
tree | 06a210b4406b9c62e19b7e8e3cb9fe3b4d9f590e /usr.bin/ssh/ssh.c | |
parent | The widget mapping code has been written back when I was only working on (diff) | |
download | wireguard-openbsd-af426ca7faf8a8b04e8a69c4940b084d6b821867.tar.xz wireguard-openbsd-af426ca7faf8a8b04e8a69c4940b084d6b821867.zip |
allow for long home dir paths (bz #1615). ok deraadt
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r-- | usr.bin/ssh/ssh.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index 74c1510c84c..0408af63052 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.325 2009/03/17 21:37:00 markus Exp $ */ +/* $OpenBSD: ssh.c,v 1.326 2009/07/02 02:11:47 dtucker Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -42,6 +42,7 @@ #include <sys/types.h> #include <sys/ioctl.h> +#include <sys/param.h> #include <sys/queue.h> #include <sys/resource.h> #include <sys/socket.h> @@ -195,8 +196,8 @@ void muxserver_listen(void); int main(int ac, char **av) { - int i, opt, exit_status, use_syslog; - char *p, *cp, *line, *argv0, buf[256]; + int i, r, opt, exit_status, use_syslog; + char *p, *cp, *line, *argv0, buf[MAXPATHLEN]; struct stat st; struct passwd *pw; int dummy, timeout_ms; @@ -601,9 +602,10 @@ main(int ac, char **av) fatal("Can't open user config file %.100s: " "%.100s", config, strerror(errno)); } else { - snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir, + r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, _PATH_SSH_USER_CONFFILE); - (void)read_config_file(buf, host, &options, 1); + if (r > 0 && (size_t)r < sizeof(buf)) + (void)read_config_file(buf, host, &options, 1); /* Read systemwide configuration file after use config. */ (void)read_config_file(_PATH_HOST_CONFIG_FILE, host, @@ -748,9 +750,9 @@ main(int ac, char **av) * Now that we are back to our own permissions, create ~/.ssh * directory if it doesn't already exist. */ - snprintf(buf, sizeof buf, "%.100s%s%.100s", pw->pw_dir, + r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir, strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR); - if (stat(buf, &st) < 0) + if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0) if (mkdir(buf, 0700) < 0) error("Could not create directory '%.200s'.", buf); |