summaryrefslogtreecommitdiffstats
path: root/libexec/bootpd/bootpd.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-04-07 08:27:45 +0000
committerbrian <brian@FreeBSD.org>1999-04-07 08:27:45 +0000
commitc6c6c7de65eae103002ebb9bee8881e1e2e903df (patch)
tree18fb09ba4ed57096b2a23fd9d28689784a00024b /libexec/bootpd/bootpd.c
parent32ff8071a15df941cbe4d98c0badea284464f320 (diff)
downloadFreeBSD-src-c6c6c7de65eae103002ebb9bee8881e1e2e903df.zip
FreeBSD-src-c6c6c7de65eae103002ebb9bee8881e1e2e903df.tar.gz
Ensure that things returned by gethostname() and
friends are terminated and allow for a maximum host name length of MAXHOSTNAMELEN - 1. Put parenthesis around sizeof args. Make some variables static. Fix telnetd -u (broken by my last commit) Prompted by: bde
Diffstat (limited to 'libexec/bootpd/bootpd.c')
-rw-r--r--libexec/bootpd/bootpd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libexec/bootpd/bootpd.c b/libexec/bootpd/bootpd.c
index 6d6a74f..b4cace6 100644
--- a/libexec/bootpd/bootpd.c
+++ b/libexec/bootpd/bootpd.c
@@ -19,7 +19,7 @@ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
- $Id: bootpd.c,v 1.9 1998/12/12 20:56:53 dillon Exp $
+ $Id: bootpd.c,v 1.10 1998/12/13 21:02:28 eivind Exp $
************************************************************************/
@@ -162,7 +162,8 @@ char *progname;
char *chdir_path;
struct in_addr my_ip_addr;
-char *hostname, default_hostname[MAXHOSTNAMELEN + 1];
+static const char *hostname;
+static char default_hostname[MAXHOSTNAMELEN];
/* Flags set by signal catcher. */
PRIVATE int do_readtab = 0;
@@ -255,10 +256,11 @@ main(argc, argv)
stmp = NULL;
timeout = &actualtimeout;
- if (gethostname(default_hostname, MAXHOSTNAMELEN) < 0) {
+ if (gethostname(default_hostname, sizeof(default_hostname) - 1) < 0) {
report(LOG_ERR, "bootpd: can't get hostname\n");
exit(1);
}
+ default_hostname[sizeof(default_hostname) - 1] = '\0';
hostname = default_hostname;
/*
OpenPOWER on IntegriCloud