summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2009-07-06 07:16:56 +1000
committerDarren Tucker <dtucker@zip.com.au>2009-07-06 07:16:56 +1000
commit199b1340a85de9f241935bc0fe56b71258839220 (patch)
tree441893db0b56a9ff0e6674346ea74aa5d4cc8663 /ssh.c
parentcd6b1a27cbb9400565811f908ca536937d875b8f (diff)
- dtucker@cvs.openbsd.org 2009/07/02 02:11:47
[ssh.c] allow for long home dir paths (bz #1615). ok deraadt (based in part on a patch from jchadima at redhat)
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/ssh.c b/ssh.c
index 96134680d..adfe60e4b 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.325 2009/03/17 21:37:00 markus Exp $ */ 1/* $OpenBSD: ssh.c,v 1.326 2009/07/02 02:11:47 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -48,6 +48,7 @@
48#endif 48#endif
49#include <sys/resource.h> 49#include <sys/resource.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/param.h>
51#include <sys/socket.h> 52#include <sys/socket.h>
52 53
53#include <ctype.h> 54#include <ctype.h>
@@ -203,8 +204,8 @@ void muxserver_listen(void);
203int 204int
204main(int ac, char **av) 205main(int ac, char **av)
205{ 206{
206 int i, opt, exit_status, use_syslog; 207 int i, r, opt, exit_status, use_syslog;
207 char *p, *cp, *line, *argv0, buf[256]; 208 char *p, *cp, *line, *argv0, buf[MAXPATHLEN];
208 struct stat st; 209 struct stat st;
209 struct passwd *pw; 210 struct passwd *pw;
210 int dummy, timeout_ms; 211 int dummy, timeout_ms;
@@ -614,9 +615,10 @@ main(int ac, char **av)
614 fatal("Can't open user config file %.100s: " 615 fatal("Can't open user config file %.100s: "
615 "%.100s", config, strerror(errno)); 616 "%.100s", config, strerror(errno));
616 } else { 617 } else {
617 snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir, 618 r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir,
618 _PATH_SSH_USER_CONFFILE); 619 _PATH_SSH_USER_CONFFILE);
619 (void)read_config_file(buf, host, &options, 1); 620 if (r > 0 && (size_t)r < sizeof(buf))
621 (void)read_config_file(buf, host, &options, 1);
620 622
621 /* Read systemwide configuration file after use config. */ 623 /* Read systemwide configuration file after use config. */
622 (void)read_config_file(_PATH_HOST_CONFIG_FILE, host, 624 (void)read_config_file(_PATH_HOST_CONFIG_FILE, host,
@@ -767,9 +769,9 @@ main(int ac, char **av)
767 * Now that we are back to our own permissions, create ~/.ssh 769 * Now that we are back to our own permissions, create ~/.ssh
768 * directory if it doesn't already exist. 770 * directory if it doesn't already exist.
769 */ 771 */
770 snprintf(buf, sizeof buf, "%.100s%s%.100s", pw->pw_dir, 772 r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir,
771 strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR); 773 strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR);
772 if (stat(buf, &st) < 0) 774 if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0)
773 if (mkdir(buf, 0700) < 0) 775 if (mkdir(buf, 0700) < 0)
774 error("Could not create directory '%.200s'.", buf); 776 error("Could not create directory '%.200s'.", buf);
775 777