[ssh.c]
     allow for long home dir paths (bz #1615).  ok deraadt
     (based in part on a patch from jchadima at redhat)
This commit is contained in:
Darren Tucker 2009-07-06 07:16:56 +10:00
parent cd6b1a27cb
commit 199b1340a8
2 changed files with 13 additions and 7 deletions

View File

@ -19,6 +19,10 @@
- markus@cvs.openbsd.org 2009/06/30 14:54:40 - markus@cvs.openbsd.org 2009/06/30 14:54:40
[version.h] [version.h]
crank version; ok deraadt crank version; ok deraadt
- 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)
20090622 20090622
- (dtucker) OpenBSD CVS Sync - (dtucker) OpenBSD CVS Sync

16
ssh.c
View File

@ -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> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -48,6 +48,7 @@
#endif #endif
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <ctype.h> #include <ctype.h>
@ -203,8 +204,8 @@ void muxserver_listen(void);
int int
main(int ac, char **av) main(int ac, char **av)
{ {
int i, opt, exit_status, use_syslog; int i, r, opt, exit_status, use_syslog;
char *p, *cp, *line, *argv0, buf[256]; char *p, *cp, *line, *argv0, buf[MAXPATHLEN];
struct stat st; struct stat st;
struct passwd *pw; struct passwd *pw;
int dummy, timeout_ms; int dummy, timeout_ms;
@ -614,9 +615,10 @@ main(int ac, char **av)
fatal("Can't open user config file %.100s: " fatal("Can't open user config file %.100s: "
"%.100s", config, strerror(errno)); "%.100s", config, strerror(errno));
} else { } else {
snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir, r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir,
_PATH_SSH_USER_CONFFILE); _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. */ /* Read systemwide configuration file after use config. */
(void)read_config_file(_PATH_HOST_CONFIG_FILE, host, (void)read_config_file(_PATH_HOST_CONFIG_FILE, host,
@ -767,9 +769,9 @@ main(int ac, char **av)
* Now that we are back to our own permissions, create ~/.ssh * Now that we are back to our own permissions, create ~/.ssh
* directory if it doesn't already exist. * 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); 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) if (mkdir(buf, 0700) < 0)
error("Could not create directory '%.200s'.", buf); error("Could not create directory '%.200s'.", buf);