diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-10-28 00:32:31 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-10-28 00:32:31 +0000 |
commit | fa6e21fe26e8ddb6307c10773b6abf6320ab89c1 (patch) | |
tree | 0494e39cb9f9495d6ac1e3d98012a7d9ad8b3a4b | |
parent | f3fe9339037d34221a416e8fcb28676b1a4929cc (diff) |
Safe $HOME usage.
-rw-r--r-- | usr.bin/ftp/ruserpass.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/ftp/ruserpass.c b/usr.bin/ftp/ruserpass.c index 430c386df62..0ddd3d6689e 100644 --- a/usr.bin/ftp/ruserpass.c +++ b/usr.bin/ftp/ruserpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ruserpass.c,v 1.2 1996/06/26 05:33:39 deraadt Exp $ */ +/* $OpenBSD: ruserpass.c,v 1.3 1996/10/28 00:32:30 millert Exp $ */ /* $NetBSD: ruserpass.c,v 1.6 1995/09/08 01:06:43 tls Exp $ */ /* @@ -90,7 +90,12 @@ ruserpass(host, aname, apass, aacct) hdir = getenv("HOME"); if (hdir == NULL) hdir = "."; - (void) sprintf(buf, "%s/.netrc", hdir); + if (strlen(hdir) + 7 < sizeof(buf)) { + (void) sprintf(buf, "%s/.netrc", hdir); + } else { + warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG)); + return (0); + } cfile = fopen(buf, "r"); if (cfile == NULL) { if (errno != ENOENT) |