diff options
author | mrg <mrg@NetBSD.org> | 1998-07-06 06:56:06 +0000 |
---|---|---|
committer | mrg <mrg@NetBSD.org> | 1998-07-06 06:56:06 +0000 |
commit | 4b973b99b26ebfe9f372367f03ac93522313fac8 (patch) | |
tree | 90f90baf999f222f428250fbaf1663ea168c5b86 /hunt/hunt | |
parent | c0faadd28817c18c672c1b7b191cea09b1a91946 (diff) | |
download | bsdgames-darwin-4b973b99b26ebfe9f372367f03ac93522313fac8.tar.gz bsdgames-darwin-4b973b99b26ebfe9f372367f03ac93522313fac8.tar.zst bsdgames-darwin-4b973b99b26ebfe9f372367f03ac93522313fac8.zip |
- use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
Diffstat (limited to 'hunt/hunt')
-rw-r--r-- | hunt/hunt/hunt.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c index d914132b..48fb801f 100644 --- a/hunt/hunt/hunt.c +++ b/hunt/hunt/hunt.c @@ -1,4 +1,4 @@ -/* $NetBSD: hunt.c,v 1.5 1998/03/29 04:50:29 mrg Exp $ */ +/* $NetBSD: hunt.c,v 1.6 1998/07/06 07:00:15 mrg Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,7 +7,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: hunt.c,v 1.5 1998/03/29 04:50:29 mrg Exp $"); +__RCSID("$NetBSD: hunt.c,v 1.6 1998/07/06 07:00:15 mrg Exp $"); #endif /* not lint */ # include <sys/stat.h> @@ -386,7 +386,7 @@ list_drivers() static SOCKET test; int test_socket; int namelen; - char local_name[256]; + char local_name[MAXHOSTNAMELEN + 1]; static int initial = TRUE; static struct in_addr local_address; struct hostent *hp; @@ -412,6 +412,7 @@ list_drivers() leave(1, "Sorry, I have no name."); /* NOTREACHED */ } + local_name[sizeof(local_name) - 1] = '\0'; if ((hp = gethostbyname(local_name)) == NULL) { leave(1, "Can't find myself."); /* NOTREACHED */ |