diff options
author | Damien Miller <djm@mindrot.org> | 2001-07-11 21:32:20 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2001-07-11 21:32:20 +1000 |
commit | eec0c25f2a1704b871ceafff4c3cc96dd985b63b (patch) | |
tree | d3bcca317d084633d6596774e456d1849f9c6f61 /auth.c | |
parent | 024acc46e6d145708881b854c84b0eb879550c38 (diff) |
- (djm) dirname(3) may modify its argument on glibc and other systems.
Patch from markus@, spotted by Tom Holroyd <tomh@po.crl.go.jp>
Diffstat (limited to 'auth.c')
-rw-r--r-- | auth.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -368,7 +368,11 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, char *cp; struct stat st; - strlcpy(homedir, dirname(pw->pw_dir), sizeof(homedir)); + strlcpy(homedir, pw->pw_dir, sizeof(homedir)); + if ((cp = dirname(homedir)) == NULL) + strlcpy(homedir, "/", sizeof(homedir)); + else + memmove(homedir, cp, strlen(cp)); if (realpath(file, buf) == NULL) { snprintf(err, errlen, "realpath %s failed: %s", file, |