diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-03 07:27:46 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-03 07:27:46 +0000 |
commit | ffb13ef1b4c6817ae6a8cbd71a67f17f44ccf79e (patch) | |
tree | 4e90c8a4ee4864eeada7b53e07d6354eb470dc54 | |
parent | 3ed56de53e8d89686c93538c29f1d0ed22d50e4e (diff) |
constrain to MAXHOSTNAMELEN
-rw-r--r-- | lib/libc/net/getnetent.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/net/getnetent.c b/lib/libc/net/getnetent.c index 862596c40fa..8c3ced2214d 100644 --- a/lib/libc/net/getnetent.c +++ b/lib/libc/net/getnetent.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: getnetent.c,v 1.4 1996/08/19 08:28:47 tholo Exp $"; +static char rcsid[] = "$OpenBSD: getnetent.c,v 1.5 1996/09/03 07:27:45 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -91,6 +91,8 @@ again: goto again; *cp = '\0'; net.n_name = p; + if (strlen(net.n_name) >= MAXHOSTNAMELEN-1) + net.n_name[MAXHOSTNAMELEN-1] = '\0'; cp = strpbrk(p, " \t"); if (cp == NULL) goto again; @@ -110,8 +112,11 @@ again: cp++; continue; } - if (q < &net_aliases[MAXALIASES - 1]) + if (q < &net_aliases[MAXALIASES - 1]) { *q++ = cp; + if (strlen(cp) >= MAXHOSTNAMELEN-1) + cp[MAXHOSTNAMELEN-1] = '\0'; + } cp = strpbrk(cp, " \t"); if (cp != NULL) *cp++ = '\0'; |