summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Jodeit <moritz@cvs.openbsd.org>2007-03-22 15:25:18 +0000
committerMoritz Jodeit <moritz@cvs.openbsd.org>2007-03-22 15:25:18 +0000
commit4a3b1290032ea2e8eccc0c79925a932b7a5a82fb (patch)
tree8d3274ae80aa82e7a78269a28b0ab29aafa3f7c2
parentfae34ae78b89efb1983ce5940739400367bc5359 (diff)
Remove wrong length check, which ignored the '/' character
and let snprintf(3) decide if the path fitted into the buffer. Inspired by a diff from Nicholas Marriott. OK millert@ ray@
-rw-r--r--usr.bin/ftp/ruserpass.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/usr.bin/ftp/ruserpass.c b/usr.bin/ftp/ruserpass.c
index 8cf986b1c37..400a5c8b426 100644
--- a/usr.bin/ftp/ruserpass.c
+++ b/usr.bin/ftp/ruserpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ruserpass.c,v 1.21 2007/03/22 11:35:02 moritz Exp $ */
+/* $OpenBSD: ruserpass.c,v 1.22 2007/03/22 15:25:17 moritz Exp $ */
/* $NetBSD: ruserpass.c,v 1.14 1997/07/20 09:46:01 lukem Exp $ */
/*
@@ -35,7 +35,7 @@
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#else
#ifndef SMALL
-static const char rcsid[] = "$OpenBSD: ruserpass.c,v 1.21 2007/03/22 11:35:02 moritz Exp $";
+static const char rcsid[] = "$OpenBSD: ruserpass.c,v 1.22 2007/03/22 15:25:17 moritz Exp $";
#endif /* SMALL */
#endif
#endif /* not lint */
@@ -91,9 +91,8 @@ ruserpass(const char *host, char **aname, char **apass, char **aacct)
hdir = getenv("HOME");
if (hdir == NULL || *hdir == '\0')
return (0);
- if (strlen(hdir) + sizeof(".netrc") < sizeof(buf)) {
- (void)snprintf(buf, sizeof buf, "%s/.netrc", hdir);
- } else {
+ i = snprintf(buf, sizeof(buf), "%s/.netrc", hdir);
+ if (i < 0 || i >= sizeof(buf)) {
warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG));
return (0);
}