diff options
author | kris <kris@FreeBSD.org> | 2000-08-04 10:53:37 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2000-08-04 10:53:37 +0000 |
commit | 910d78b1f5c37c3517a485c6b6c06f6344c17652 (patch) | |
tree | 972deaad9992fff2924cf1a8e63ef4cdfdd27897 /lib/libc/rpc | |
parent | 6e733bdce9b2b694e05a6330fe81362dabc91c4c (diff) | |
download | FreeBSD-src-910d78b1f5c37c3517a485c6b6c06f6344c17652.zip FreeBSD-src-910d78b1f5c37c3517a485c6b6c06f6344c17652.tar.gz |
Correct string length bounds checking.
Diffstat (limited to 'lib/libc/rpc')
-rw-r--r-- | lib/libc/rpc/netname.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/rpc/netname.c b/lib/libc/rpc/netname.c index 22167be..58b7e45 100644 --- a/lib/libc/rpc/netname.c +++ b/lib/libc/rpc/netname.c @@ -26,6 +26,8 @@ * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 + * + * $FreeBSD$ */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)netname.c 1.8 91/03/11 Copyr 1986 Sun Micro"; @@ -90,7 +92,7 @@ user2netname(netname, uid, domain) { char *dfltdom; -#define MAXIPRINT (11) /* max length of printed integer */ +#define MAXIPRINT (20) /* max length of printed integer */ if (domain == NULL) { if (_rpc_get_default_domain(&dfltdom) != 0) { @@ -98,7 +100,7 @@ user2netname(netname, uid, domain) } domain = dfltdom; } - if (strlen(domain) + 1 + MAXIPRINT > MAXNETNAMELEN) { + if (strlen(domain) + 1 + MAXIPRINT + 1 + strlen(OPSYS) > MAXNETNAMELEN) { return (0); } (void) sprintf(netname, "%s.%ld@%s", OPSYS, (u_long)uid, domain); @@ -128,7 +130,7 @@ host2netname(netname, host, domain) (void) gethostname(hostname, sizeof(hostname)); host = hostname; } - if (strlen(domain) + 1 + strlen(host) > MAXNETNAMELEN) { + if (strlen(domain) + 1 + strlen(host) + 1 + strlen(OPSYS) > MAXNETNAMELEN) { return (0); } (void) sprintf(netname, "%s.%s@%s", OPSYS, host, domain); |