summaryrefslogtreecommitdiffstats
path: root/hunt/hunt
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>1998-07-06 06:56:06 +0000
committermrg <mrg@NetBSD.org>1998-07-06 06:56:06 +0000
commit4b973b99b26ebfe9f372367f03ac93522313fac8 (patch)
tree90f90baf999f222f428250fbaf1663ea168c5b86 /hunt/hunt
parentc0faadd28817c18c672c1b7b191cea09b1a91946 (diff)
downloadbsdgames-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.c7
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 */