This commit was generated by cvs2svn to compensate for changes in r73393,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
Kris Kennaway 2001-03-03 23:45:43 +00:00
commit 30b14dd1d0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=73394
2 changed files with 35 additions and 16 deletions

View File

@ -528,14 +528,26 @@ main(argc, argv)
*/ */
shlvl(1); shlvl(1);
if ((tcp = getenv("HOME")) != NULL) if ((tcp = getenv("HOME")) != NULL) {
cp = quote(SAVE(tcp)); if (strlen(tcp) >= MAXPATHLEN) {
else struct passwd *pw;
if ((pw = getpwuid(getuid())) != NULL)
cp = quote(SAVE(pw->pw_dir));
else {
tcp[MAXPATHLEN-1] = '\0';
cp = quote(SAVE(tcp));
}
} else {
cp = quote(SAVE(tcp));
}
} else
cp = NULL; cp = NULL;
if (cp == NULL) if (cp == NULL)
fast = 1; /* No home -> can't read scripts */ fast = 1; /* No home -> can't read scripts */
else else
set(STRhome, cp, VAR_READWRITE); set(STRhome, cp, VAR_READWRITE);
dinit(cp); /* dinit thinks that HOME == cwd in a login dinit(cp); /* dinit thinks that HOME == cwd in a login
* shell */ * shell */
/* /*

View File

@ -814,6 +814,7 @@ dcanon(cp, p)
#ifdef apollo #ifdef apollo
bool slashslash; bool slashslash;
#endif /* apollo */ #endif /* apollo */
size_t clen;
#ifdef S_IFLNK /* if we have symlinks */ #ifdef S_IFLNK /* if we have symlinks */
Char link[MAXPATHLEN]; Char link[MAXPATHLEN];
@ -823,23 +824,34 @@ dcanon(cp, p)
#endif /* S_IFLNK */ #endif /* S_IFLNK */
/* /*
* kim: if the path given is too long abort(). * if the path given is too long truncate it!
*/ */
if (Strlen(cp) >= MAXPATHLEN) if ((clen = Strlen(cp)) >= MAXPATHLEN)
abort(); cp[clen = MAXPATHLEN - 1] = '\0';
/* /*
* christos: if the path given does not start with a slash prepend cwd. If * christos: if the path given does not start with a slash prepend cwd. If
* cwd does not start with a slash or the result would be too long abort(). * cwd does not start with a slash or the result would be too long try to
* correct it.
*/ */
if (!ABSOLUTEP(cp)) { if (!ABSOLUTEP(cp)) {
Char tmpdir[MAXPATHLEN]; Char tmpdir[MAXPATHLEN];
size_t len;
p1 = varval(STRcwd); p1 = varval(STRcwd);
if (p1 == STRNULL || !ABSOLUTEP(p1)) if (p1 == STRNULL || !ABSOLUTEP(p1)) {
abort(); char *tmp = (char *)getcwd((char *)tmpdir, sizeof(tmpdir));
if (Strlen(p1) + Strlen(cp) + 1 >= MAXPATHLEN) if (tmp == NULL || *tmp == '\0') {
abort(); xprintf("%s: %s\n", progname, strerror(errno));
set(STRcwd, SAVE("/"), VAR_READWRITE|VAR_NOGLOB);
} else {
set(STRcwd, SAVE(tmp), VAR_READWRITE|VAR_NOGLOB);
}
p1 = varval(STRcwd);
}
len = Strlen(p1);
if (len + clen + 1 >= MAXPATHLEN)
cp[MAXPATHLEN - (len + 1)] = '\0';
(void) Strcpy(tmpdir, p1); (void) Strcpy(tmpdir, p1);
(void) Strcat(tmpdir, STRslash); (void) Strcat(tmpdir, STRslash);
(void) Strcat(tmpdir, cp); (void) Strcat(tmpdir, cp);
@ -847,11 +859,6 @@ dcanon(cp, p)
cp = p = Strsave(tmpdir); cp = p = Strsave(tmpdir);
} }
#ifdef COMMENT
if (*cp != '/')
abort();
#endif /* COMMENT */
#ifdef apollo #ifdef apollo
slashslash = (cp[0] == '/' && cp[1] == '/'); slashslash = (cp[0] == '/' && cp[1] == '/');
#endif /* apollo */ #endif /* apollo */