- 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
This commit is contained in:
mrg 1998-07-06 06:56:06 +00:00
parent 2beab49a06
commit 32f519716b
45 changed files with 207 additions and 153 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: net.c,v 1.30 1998/06/20 13:05:50 mrg Exp $ */
/* $NetBSD: net.c,v 1.31 1998/07/06 06:59:36 mrg Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -91,7 +91,7 @@ get_ifinterface_info()
char *textbuf;
int textsize;
char *t;
char hostname[MAXHOSTNAMELEN];
char hostname[MAXHOSTNAMELEN + 1];
/* First look to see if the selected interface is already configured. */
textsize = collect(T_OUTPUT, &textbuf, "/sbin/ifconfig %s 2>/dev/null",
@ -117,8 +117,10 @@ get_ifinterface_info()
}
/* Check host (and domain?) name */
if (gethostname(hostname, sizeof(hostname)) == 0)
if (gethostname(hostname, sizeof(hostname)) == 0) {
hostname[sizeof(hostname) - 1] = '\0';
strncpy(net_host, hostname, sizeof(net_host));
}
}
/*

View File

@ -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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: get_names.c,v 1.2 1997/10/10 16:33:35 lukem Exp $ */
/* $NetBSD: get_names.c,v 1.3 1998/07/06 07:00:31 mrg Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
@ -7,7 +7,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: get_names.c,v 1.2 1997/10/10 16:33:35 lukem Exp $");
__RCSID("$NetBSD: get_names.c,v 1.3 1998/07/06 07:00:31 mrg Exp $");
#endif /* not lint */
#include "bsd.h"
@ -24,7 +24,7 @@ __RCSID("$NetBSD: get_names.c,v 1.2 1997/10/10 16:33:35 lukem Exp $");
extern CTL_MSG msg;
static char hostname[MAXHOSTNAMELEN];
static char hostname[MAXHOSTNAMELEN + 1];
char *my_machine_name;
/*
@ -52,7 +52,8 @@ get_local_name(my_name)
msg.ctl_addr.sin_family = htons(AF_INET);
# endif
(void) gethostname(hostname, sizeof (hostname));
(void)gethostname(hostname, sizeof (hostname));
hostname[sizeof(hostname) - 1] = '\0';
my_machine_name = hostname;
/* look up the address of the local host */
hp = gethostbyname(my_machine_name);

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_init.c,v 1.17 1998/02/02 22:36:15 perry Exp $ */
/* $NetBSD: res_init.c,v 1.18 1998/07/06 07:00:46 mrg Exp $ */
/*-
* Copyright (c) 1985, 1989, 1993
@ -59,7 +59,7 @@
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static char rcsid[] = "Id: res_init.c,v 8.8 1997/06/01 20:34:37 vixie Exp ";
#else
__RCSID("$NetBSD: res_init.c,v 1.17 1998/02/02 22:36:15 perry Exp $");
__RCSID("$NetBSD: res_init.c,v 1.18 1998/07/06 07:00:46 mrg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -344,8 +344,11 @@ res_init()
(void) fclose(fp);
}
if (_res.defdname[0] == 0) {
if (gethostname(buf, sizeof(_res.defdname) - 1) == 0 &&
(cp = strchr(buf, '.')))
int rv;
rv = gethostname(buf, sizeof(_res.defdname));
_res.defdname[sizeof(_res.defdname) - 1] = '\0';
if (rv == 0 && (cp = strchr(buf, '.')))
(void)strncpy(_res.defdname, cp + 1, sizeof(_res.defdname) - 1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: auth_unix.c,v 1.10 1998/02/13 05:52:13 lukem Exp $ */
/* $NetBSD: auth_unix.c,v 1.11 1998/07/06 07:01:01 mrg Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";
#else
__RCSID("$NetBSD: auth_unix.c,v 1.10 1998/02/13 05:52:13 lukem Exp $");
__RCSID("$NetBSD: auth_unix.c,v 1.11 1998/07/06 07:01:01 mrg Exp $");
#endif
#endif
@ -53,6 +53,8 @@ __RCSID("$NetBSD: auth_unix.c,v 1.10 1998/02/13 05:52:13 lukem Exp $");
#include "namespace.h"
#include <sys/param.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
@ -187,14 +189,14 @@ AUTH *
authunix_create_default()
{
int len;
char machname[MAX_MACHINE_NAME + 1];
char machname[MAXHOSTNAMELEN + 1];
int uid;
int gid;
int gids[NGRPS];
if (gethostname(machname, MAX_MACHINE_NAME) == -1)
if (gethostname(machname, sizeof machname) == -1)
abort();
machname[MAX_MACHINE_NAME] = 0;
machname[sizeof(machname) - 1] = 0;
uid = geteuid();
gid = getegid();
if ((len = getgroups(NGRPS, gids)) < 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ruserpass.c,v 1.2 1998/03/19 18:06:15 tv Exp $ */
/* $NetBSD: ruserpass.c,v 1.3 1998/07/06 07:01:16 mrg Exp $ */
/*
* Copyright (c) 1985, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#else
__RCSID("$NetBSD: ruserpass.c,v 1.2 1998/03/19 18:06:15 tv Exp $");
__RCSID("$NetBSD: ruserpass.c,v 1.3 1998/07/06 07:01:16 mrg Exp $");
#endif
#endif /* not lint */
@ -98,7 +98,7 @@ ruserpass(host, aname, apass)
char **aname, **apass;
{
char *hdir, buf[BUFSIZ], *tmp;
char myname[MAXHOSTNAMELEN], *mydomain;
char myname[MAXHOSTNAMELEN + 1], *mydomain;
int t, i, c, usedefault = 0;
struct stat stb;
@ -119,6 +119,8 @@ ruserpass(host, aname, apass)
}
if (gethostname(myname, sizeof(myname)) < 0)
myname[0] = '\0';
else
myname[sizeof(myname) - 1] = '\0';
if ((mydomain = strchr(myname, '.')) == NULL)
mydomain = "";
next:

View File

@ -1,4 +1,4 @@
/* $NetBSD: commands.c,v 1.20 1998/03/30 02:30:08 mrg Exp $ */
/* $NetBSD: commands.c,v 1.21 1998/07/06 06:56:06 mrg Exp $ */
/*
* Copyright (c) 1988, 1990, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: commands.c,v 1.20 1998/03/30 02:30:08 mrg Exp $");
__RCSID("$NetBSD: commands.c,v 1.21 1998/07/06 06:56:06 mrg Exp $");
#endif
#endif /* not lint */
@ -1732,10 +1732,11 @@ env_init()
if ((ep = env_find("DISPLAY"))
&& ((*ep->value == ':')
|| (strncmp((char *)ep->value, "unix:", 5) == 0))) {
char hbuf[256+1];
char hbuf[MAXHOSTNAMELEN + 1];
char *cp2 = strchr((char *)ep->value, ':');
gethostname(hbuf, 256);
gethostname(hbuf, sizeof hbuf);
hostname[sizeof(hostname) - 1] = '\0';
hbuf[256] = '\0';
cp = (char *)malloc(strlen(hbuf) + strlen(cp2) + 1);
sprintf((char *)cp, "%s%s", hbuf, cp2);

View File

@ -1,4 +1,4 @@
/* $NetBSD: telnet.c,v 1.9 1998/02/27 10:44:14 christos Exp $ */
/* $NetBSD: telnet.c,v 1.10 1998/07/06 06:56:06 mrg Exp $ */
/*
* Copyright (c) 1988, 1990, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: telnet.c,v 1.9 1998/02/27 10:44:14 christos Exp $");
__RCSID("$NetBSD: telnet.c,v 1.10 1998/07/06 06:56:06 mrg Exp $");
#endif
#endif /* not lint */
@ -2181,7 +2181,7 @@ telnet(user)
#if defined(AUTHENTICATION)
{
static char local_host[256] = { 0 };
static char local_host[MAXHOSTNAMELEN + 1] = { 0 };
if (!local_host[0]) {
gethostname(local_host, sizeof(local_host));

View File

@ -1,4 +1,4 @@
/* $NetBSD: system.c,v 1.8 1998/03/04 13:44:48 christos Exp $ */
/* $NetBSD: system.c,v 1.9 1998/07/06 07:01:33 mrg Exp $ */
/*-
* Copyright (c) 1988 The Regents of the University of California.
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)system.c 4.5 (Berkeley) 4/26/91";
#else
__RCSID("$NetBSD: system.c,v 1.8 1998/03/04 13:44:48 christos Exp $");
__RCSID("$NetBSD: system.c,v 1.9 1998/07/06 07:01:33 mrg Exp $");
#endif
#endif /* not lint */
@ -657,7 +657,7 @@ char *argv[];
{
int length;
struct sockaddr_in server;
char sockNAME[100];
char sockNAME[128];
static char **whereAPI = 0;
int fd;
struct timeval tv;
@ -727,6 +727,7 @@ char *argv[];
/* Get name to advertise in address list */
strcpy(sockNAME, "API3270=");
gethostname(sockNAME+strlen(sockNAME), sizeof sockNAME-strlen(sockNAME));
sockNAME[sizeof(sockNAME) - 1] = '\0';
if (strlen(sockNAME) > (sizeof sockNAME-(10+strlen(keyname)))) {
fprintf(stderr, "Local hostname too large; using 'localhost'.\n");
strcpy(sockNAME, "localhost");

View File

@ -1,4 +1,4 @@
/* $NetBSD: recover.c,v 1.4 1998/01/09 08:07:04 perry Exp $ */
/* $NetBSD: recover.c,v 1.5 1998/07/06 07:01:52 mrg Exp $ */
/*-
* Copyright (c) 1993, 1994
@ -351,7 +351,7 @@ rcv_mailfile(sp, issync, cp_path)
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 1024
#endif
char host[MAXHOSTNAMELEN];
char host[MAXHOSTNAMELEN + 1];
if ((pw = getpwuid(uid = getuid())) == NULL) {
msgq(sp, M_ERR,
@ -400,6 +400,7 @@ rcv_mailfile(sp, issync, cp_path)
++p;
(void)time(&now);
(void)gethostname(host, sizeof(host));
host[sizeof(host) - 1] = '\0';
len = snprintf(buf, sizeof(buf),
"%s%s\n%s%s\n%s\n%s\n%s%s\n%s%s\n%s\n\n",
VI_FHEADER, t, /* Non-standard. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: w.c,v 1.28 1998/04/02 11:39:40 kleink Exp $ */
/* $NetBSD: w.c,v 1.29 1998/07/06 06:56:43 mrg Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94";
#else
__RCSID("$NetBSD: w.c,v 1.28 1998/04/02 11:39:40 kleink Exp $");
__RCSID("$NetBSD: w.c,v 1.29 1998/07/06 06:56:43 mrg Exp $");
#endif
#endif /* not lint */
@ -98,7 +98,7 @@ int header = 1; /* true if -h flag: don't print heading */
int nflag; /* true if -n flag: don't convert addrs */
int sortidle; /* sort bu idle time */
char *sel_user; /* login of particular user selected */
char domain[MAXHOSTNAMELEN];
char domain[MAXHOSTNAMELEN + 1];
/*
* One of these per active utmp entry.
@ -282,14 +282,16 @@ main(argc, argv)
}
}
if (!nflag)
if (gethostname(domain, sizeof(domain) - 1) < 0 ||
(p = strchr(domain, '.')) == 0)
if (!nflag) {
int rv;
rv = gethostname(domain, sizeof(domain));
domain[sizeof(domain) - 1] = '\0';
if (rv < 0 || (p = strchr(domain, '.')) == 0)
domain[0] = '\0';
else {
domain[sizeof(domain) - 1] = '\0';
else
memmove(domain, p, strlen(p) + 1);
}
}
for (ep = ehead; ep != NULL; ep = ep->next) {
p = *ep->utmp.ut_host ? ep->utmp.ut_host : "-";
@ -451,5 +453,5 @@ usage(wcmd)
"usage: w: [-hin] [-M core] [-N system] [user]\n");
else
(void)fprintf(stderr, "uptime\n");
exit (1);
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: write.c,v 1.10 1997/10/20 03:24:44 lukem Exp $ */
/* $NetBSD: write.c,v 1.11 1998/07/06 06:57:02 mrg Exp $ */
/*
* Copyright (c) 1989, 1993
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)write.c 8.2 (Berkeley) 4/27/95";
#else
__RCSID("$NetBSD: write.c,v 1.10 1997/10/20 03:24:44 lukem Exp $");
__RCSID("$NetBSD: write.c,v 1.11 1998/07/06 06:57:02 mrg Exp $");
#endif
#endif /* not lint */
@ -258,7 +258,7 @@ do_write(tty, mytty, myuid)
char *login, *nows;
struct passwd *pwd;
time_t now;
char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
char path[MAXPATHLEN], host[MAXHOSTNAMELEN + 1], line[512];
/* Determine our login name before the we reopen() stdout */
if ((login = getlogin()) == NULL)
@ -277,6 +277,7 @@ do_write(tty, mytty, myuid)
/* print greeting */
if (gethostname(host, sizeof(host)) < 0)
(void)strncpy(host, "???", sizeof(host) - 1);
host[sizeof(host) - 1] = '\0';
now = time((time_t *)NULL);
nows = ctime(&now);
nows[16] = '\0';

View File

@ -22,7 +22,7 @@ SOFTWARE.
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: bootpd.c,v 1.8 1998/03/14 04:39:53 lukem Exp $");
__RCSID("$NetBSD: bootpd.c,v 1.9 1998/07/06 07:02:16 mrg Exp $");
#endif
/*
@ -166,7 +166,7 @@ char *pktbuf; /* Receive packet buffer */
int pktlen;
char *progname;
char *chdir_path;
char hostname[MAXHOSTNAMELEN]; /* System host name */
char hostname[MAXHOSTNAMELEN + 1]; /* System host name */
struct in_addr my_ip_addr;
/* Flags set by signal catcher. */
@ -202,8 +202,10 @@ main(argc, argv)
int standalone;
progname = strrchr(argv[0], '/');
if (progname) progname++;
else progname = argv[0];
if (progname)
progname++;
else
progname = argv[0];
/*
* Initialize logging.
@ -376,6 +378,7 @@ main(argc, argv)
fprintf(stderr, "bootpd: can't get hostname\n");
exit(1);
}
hostname[sizeof(hostname) - 1] = '\0';
}
hep = gethostbyname(hostname);
if (!hep) {

View File

@ -27,7 +27,7 @@ SOFTWARE.
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: bootpgw.c,v 1.7 1998/03/14 04:39:53 lukem Exp $");
__RCSID("$NetBSD: bootpgw.c,v 1.8 1998/07/06 07:02:17 mrg Exp $");
#endif
/*
@ -142,7 +142,7 @@ int pktlen;
char *progname;
char *servername;
char myhostname[64];
char myhostname[MAXHOSTNAMELEN + 1];
struct in_addr my_ip_addr;
@ -222,6 +222,7 @@ main(argc, argv)
stmp = NULL;
timeout = &actualtimeout;
gethostname(myhostname, sizeof(myhostname));
myhostname[sizeof(myhostname) - 1] = '\0';
hep = gethostbyname(myhostname);
if (!hep) {
printf("Can not get my IP address\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootptest.c,v 1.5 1998/03/14 04:39:53 lukem Exp $ */
/* $NetBSD: bootptest.c,v 1.6 1998/07/06 07:02:17 mrg Exp $ */
/*
* bootptest.c - Test out a bootp server.
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: bootptest.c,v 1.5 1998/03/14 04:39:53 lukem Exp $");
__RCSID("$NetBSD: bootptest.c,v 1.6 1998/07/06 07:02:17 mrg Exp $");
#endif
char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
@ -103,7 +103,7 @@ u_char eaddr[16]; /* Ethernet address */
*/
int debug = 1; /* Debugging flag (level) */
char hostname[64];
char hostname[MAXHOSTNAMELEN + 1];
char *sndbuf; /* Send packet buffer */
char *rcvbuf; /* Receive packet buffer */
@ -330,6 +330,7 @@ main(argc, argv)
} else {
/* Fill in the client IP address. */
gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname) - 1] = '\0';
hep = gethostbyname(hostname);
if (!hep) {
printf("Can not get my IP address\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: do_command.c,v 1.5 1998/01/31 14:40:28 christos Exp $ */
/* $NetBSD: do_command.c,v 1.6 1998/07/06 06:57:18 mrg Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -22,7 +22,7 @@
#if 0
static char rcsid[] = "Id: do_command.c,v 2.12 1994/01/15 20:43:43 vixie Exp ";
#else
__RCSID("$NetBSD: do_command.c,v 1.5 1998/01/31 14:40:28 christos Exp $");
__RCSID("$NetBSD: do_command.c,v 1.6 1998/07/06 06:57:18 mrg Exp $");
#endif
#endif
@ -378,10 +378,11 @@ child_process(e, u)
if (mailto) {
char **env;
char mailcmd[MAX_COMMAND];
char hostname[MAXHOSTNAMELEN];
char hostname[MAXHOSTNAMELEN + 1];
(void) gethostname(hostname, MAXHOSTNAMELEN);
(void) snprintf(mailcmd, sizeof(mailcmd),
(void)gethostname(hostname, sizeof hostname);
hostname[sizeof(hostname) - 1] = '\0';
(void)snprintf(mailcmd, sizeof(mailcmd),
MAILARGS, MAILCMD);
if (!(mail = cron_popen(mailcmd, "w"))) {
perror(MAILCMD);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsend.c,v 1.6 1998/05/29 20:46:47 veego Exp $ */
/* $NetBSD: ipsend.c,v 1.7 1998/07/06 07:02:57 mrg Exp $ */
/*
* ipsend.c (C) 1995-1997 Darren Reed
@ -178,7 +178,8 @@ char **argv;
struct in_addr gwip;
tcphdr_t *tcp;
ip_t *ip;
char *name = argv[0], host[64], *gateway = NULL, *dev = NULL;
char *name = argv[0], host[MAXHOSTNAMELEN];
char *gateway = NULL, *dev = NULL;
char *src = NULL, *dst, *s;
int mtu = 1500, olen = 0, c, nonl = 0;
@ -318,6 +319,7 @@ char **argv;
if (!src)
{
gethostname(host, sizeof(host));
host[sizeof(host) - 1] = '\0';
src = host;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: iptest.c,v 1.6 1998/05/17 16:54:28 veego Exp $ */
/* $NetBSD: iptest.c,v 1.7 1998/07/06 07:02:40 mrg Exp $ */
/*
* ipsend.c (C) 1995-1997 Darren Reed
@ -99,7 +99,8 @@ char **argv;
struct tcpiphdr *ti;
struct in_addr gwip;
ip_t *ip;
char *name = argv[0], host[64], *gateway = NULL, *dev = NULL;
char *name = argv[0], host[MAXHOSTNAMELEN + 1];
char *gateway = NULL, *dev = NULL;
char *src = NULL, *dst;
int mtu = 1500, tests = 0, pointtest = 0, c;
@ -155,6 +156,7 @@ char **argv;
if (!src)
{
gethostname(host, sizeof(host));
host[sizeof(host) - 1] = '\0';
src = host;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: common.c,v 1.12 1997/10/18 08:52:17 lukem Exp $ */
/* $NetBSD: common.c,v 1.13 1998/07/06 07:03:28 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)common.c 8.5 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: common.c,v 1.12 1997/10/18 08:52:17 lukem Exp $");
__RCSID("$NetBSD: common.c,v 1.13 1998/07/06 07:03:28 mrg Exp $");
#endif
#endif /* not lint */
@ -116,7 +116,7 @@ char *bp; /* pointer into printcap buffer. */
char *name; /* program name */
char *printer; /* printer name */
/* host machine name */
char host[MAXHOSTNAMELEN];
char host[MAXHOSTNAMELEN + 1];
char *from = host; /* client's machine name */
int remote; /* true if sending files to a remote host */
char *printcapdb[2] = { _PATH_PRINTCAP, 0 };
@ -309,7 +309,7 @@ compar(p1, p2)
char *
checkremote()
{
char name[MAXHOSTNAMELEN];
char name[MAXHOSTNAMELEN + 1];
struct hostent *hp;
static char errbuf[128];

View File

@ -1,4 +1,4 @@
/* $NetBSD: lpd.c,v 1.15 1997/10/18 08:52:23 lukem Exp $ */
/* $NetBSD: lpd.c,v 1.16 1998/07/06 07:03:28 mrg Exp $ */
/*
* Copyright (c) 1983, 1993, 1994
@ -45,7 +45,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
#else
__RCSID("$NetBSD: lpd.c,v 1.15 1997/10/18 08:52:23 lukem Exp $");
__RCSID("$NetBSD: lpd.c,v 1.16 1998/07/06 07:03:28 mrg Exp $");
#endif
#endif /* not lint */
@ -135,6 +135,7 @@ main(argc, argv)
uid = getuid();
options = 0;
gethostname(host, sizeof(host));
host[sizeof(host) - 1] = '\0';
name = argv[0];
errs = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: printjob.c,v 1.18 1997/10/19 19:40:21 mycroft Exp $ */
/* $NetBSD: printjob.c,v 1.19 1998/07/06 07:03:28 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -45,7 +45,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/95";
#else
__RCSID("$NetBSD: printjob.c,v 1.18 1997/10/19 19:40:21 mycroft Exp $");
__RCSID("$NetBSD: printjob.c,v 1.19 1998/07/06 07:03:28 mrg Exp $");
#endif
#endif /* not lint */
@ -424,8 +424,10 @@ printit(file)
if (line[1] != '\0') {
strncpy(class, line+1, sizeof(class) - 1);
class[sizeof(class)-1] = '\0';
} else if (class[0] == '\0')
} else if (class[0] == '\0') {
gethostname(class, sizeof(class));
class[sizeof(class) - 1] = '\0';
}
continue;
case 'T': /* header title for pr */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lpq.c,v 1.7 1997/10/05 15:12:18 mrg Exp $ */
/* $NetBSD: lpq.c,v 1.8 1998/07/06 07:03:28 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)lpq.c 8.3 (Berkeley) 5/10/95";
#else
__RCSID("$NetBSD: lpq.c,v 1.7 1997/10/05 15:12:18 mrg Exp $");
__RCSID("$NetBSD: lpq.c,v 1.8 1998/07/06 07:03:28 mrg Exp $");
#endif
#endif /* not lint */
@ -95,6 +95,7 @@ main(argc, argv)
name = *argv;
if (gethostname(host, sizeof(host)))
err(1, "lpq: gethostname");
host[sizeof(host) - 1] = '\0';
openlog("lpd", 0, LOG_LPR);
aflag = lflag = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lpr.c,v 1.16 1997/10/19 19:41:57 mycroft Exp $ */
/* $NetBSD: lpr.c,v 1.17 1998/07/06 07:03:28 mrg Exp $ */
/*
* Copyright (c) 1983, 1989, 1993
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)lpr.c 8.4 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: lpr.c,v 1.16 1997/10/19 19:41:57 mycroft Exp $");
__RCSID("$NetBSD: lpr.c,v 1.17 1998/07/06 07:03:28 mrg Exp $");
#endif
#endif /* not lint */
@ -147,6 +147,7 @@ main(argc, argv)
name = argv[0];
gethostname(host, sizeof (host));
host[sizeof(host) - 1] = '\0';
openlog("lpd", 0, LOG_LPR);
errs = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lprm.c,v 1.7 1997/10/05 15:12:22 mrg Exp $ */
/* $NetBSD: lprm.c,v 1.8 1998/07/06 07:03:29 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)lprm.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lprm.c,v 1.7 1997/10/05 15:12:22 mrg Exp $");
__RCSID("$NetBSD: lprm.c,v 1.8 1998/07/06 07:03:29 mrg Exp $");
#endif
#endif /* not lint */
@ -98,6 +98,7 @@ main(argc, argv)
seteuid(uid); /* be safe */
name = argv[0];
gethostname(host, sizeof(host));
host[sizeof(host) - 1] = '\0';
openlog("lpd", 0, LOG_LPR);
if ((p = getpwuid(getuid())) == NULL)
fatal("Who are you?");

View File

@ -1,4 +1,4 @@
/* $NetBSD: create.c,v 1.13 1997/10/17 11:46:35 lukem Exp $ */
/* $NetBSD: create.c,v 1.14 1998/07/06 06:57:34 mrg Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: create.c,v 1.13 1997/10/17 11:46:35 lukem Exp $");
__RCSID("$NetBSD: create.c,v 1.14 1998/07/06 06:57:34 mrg Exp $");
#endif
#endif /* not lint */
@ -80,10 +80,11 @@ cwalk()
FTS *t;
FTSENT *p;
time_t clock;
char *argv[2], host[MAXHOSTNAMELEN];
char *argv[2], host[MAXHOSTNAMELEN + 1];
(void)time(&clock);
(void)gethostname(host, sizeof(host));
host[sizeof(host) - 1] = '\0';
(void)printf(
"#\t user: %s\n#\tmachine: %s\n#\t tree: %s\n#\t date: %s",
getlogin(), host, fullpath, ctime(&clock));

View File

@ -1,11 +1,11 @@
/* $NetBSD: file.c,v 1.11 1998/05/18 23:43:57 hubertf Exp $ */
/* $NetBSD: file.c,v 1.12 1998/07/06 07:03:55 mrg Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: file.c,v 1.29 1997/10/08 07:47:54 charnier Exp";
#else
__RCSID("$NetBSD: file.c,v 1.11 1998/05/18 23:43:57 hubertf Exp $");
__RCSID("$NetBSD: file.c,v 1.12 1998/07/06 07:03:55 mrg Exp $");
#endif
#endif
@ -30,12 +30,14 @@ __RCSID("$NetBSD: file.c,v 1.11 1998/05/18 23:43:57 hubertf Exp $");
*/
#include "lib.h"
#include <sys/wait.h>
#include <err.h>
#include <ftpio.h>
#include <netdb.h>
#include <pwd.h>
#include <time.h>
#include <sys/wait.h>
/* Quick check to see if a file exists */
Boolean
@ -174,7 +176,6 @@ fileURLFilename(char *fname, char *where, int max)
return fname;
}
#define HOSTNAME_MAX 64
/*
* Try and fetch a file by URL, returning the directory name for where
* it's unpacked, if successful.
@ -182,8 +183,8 @@ fileURLFilename(char *fname, char *where, int max)
char *
fileGetURL(char *base, char *spec)
{
char host[HOSTNAME_MAX], file[FILENAME_MAX];
char pword[HOSTNAME_MAX + 40], *uname, *cp, *rp;
char host[MAXHOSTNAMELEN], file[FILENAME_MAX];
char pword[MAXHOSTNAMELEN + 40], *uname, *cp, *rp;
char fname[FILENAME_MAX];
char pen[FILENAME_MAX];
struct passwd *pw;
@ -226,7 +227,7 @@ fileGetURL(char *base, char *spec)
}
else
strcpy(fname, spec);
cp = fileURLHost(fname, host, HOSTNAME_MAX);
cp = fileURLHost(fname, host, MAXHOSTNAMELEN);
if (!*cp) {
warnx("URL `%s' has bad host part!", fname);
return NULL;
@ -248,10 +249,11 @@ fileGetURL(char *base, char *spec)
strcpy(pword, "joe@");
}
else {
char me[HOSTNAME_MAX];
char me[MAXHOSTNAMELEN + 1];
gethostname(me, HOSTNAME_MAX);
snprintf(pword, HOSTNAME_MAX + 40, "%s@%s", pw->pw_name, me);
gethostname(me, sizeof me);
me[sizeof(me) - 1] = '\0';
snprintf(pword, sizeof pword, "%s@%s", pw->pw_name, me);
}
if (Verbose)
printf("Trying to fetch %s.\n", fname);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lib.h,v 1.5 1998/06/05 11:22:20 frueauf Exp $ */
/* $NetBSD: lib.h,v 1.6 1998/07/06 07:03:56 mrg Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@ -26,16 +26,17 @@
#define _INST_LIB_LIB_H_
/* Includes */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <ctype.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/file.h>
/* Macros */
#define SUCCESS (0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: chap.c,v 1.11 1998/05/02 14:19:14 christos Exp $ */
/* $NetBSD: chap.c,v 1.12 1998/07/06 07:04:28 mrg Exp $ */
/*
* chap.c - Challenge Handshake Authentication Protocol.
@ -40,7 +40,7 @@
#if 0
static char rcsid[] = "Id: chap.c,v 1.15 1997/11/27 06:07:48 paulus Exp ";
#else
__RCSID("$NetBSD: chap.c,v 1.11 1998/05/02 14:19:14 christos Exp $");
__RCSID("$NetBSD: chap.c,v 1.12 1998/07/06 07:04:28 mrg Exp $");
#endif
#endif
@ -395,7 +395,7 @@ ChapReceiveChallenge(cstate, inp, id, len)
u_char *rchallenge;
int secret_len;
char secret[MAXSECRETLEN];
char rhostname[256];
char rhostname[MAXNAMELEN+1];
MD5_CTX mdContext;
u_char hash[MD5_SIGNATURE_SIZE];
@ -494,7 +494,7 @@ ChapReceiveResponse(cstate, inp, id, len)
u_char *remmd, remmd_len;
int secret_len, old_state;
int code;
char rhostname[256];
char rhostname[MAXNAMELEN+1];
MD5_CTX mdContext;
char secret[MAXSECRETLEN];
u_char hash[MD5_SIGNATURE_SIZE];

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.29 1998/05/02 14:19:15 christos Exp $ */
/* $NetBSD: main.c,v 1.30 1998/07/06 07:04:28 mrg Exp $ */
/*
* main.c - Point-to-Point Protocol main module
@ -24,7 +24,7 @@
#if 0
static char rcsid[] = "Id: main.c,v 1.47 1998/03/30 06:25:34 paulus Exp ";
#else
__RCSID("$NetBSD: main.c,v 1.29 1998/05/02 14:19:15 christos Exp $");
__RCSID("$NetBSD: main.c,v 1.30 1998/07/06 07:04:28 mrg Exp $");
#endif
#endif
@ -79,7 +79,7 @@ char ifname[32]; /* Interface name */
int ifunit; /* Interface unit number */
char *progname; /* Name of this program */
char hostname[MAXNAMELEN]; /* Our hostname */
char hostname[MAXNAMELEN + 1]; /* Our hostname */
static char pidfilename[MAXPATHLEN]; /* name of pid file */
static char default_devnam[MAXPATHLEN]; /* name of default device */
static pid_t pid; /* Our pid */
@ -197,11 +197,11 @@ main(argc, argv)
setlogmask(LOG_UPTO(LOG_INFO));
#endif
if (gethostname(hostname, MAXNAMELEN) < 0 ) {
if (gethostname(hostname, sizeof(hostname)) < 0 ) {
option_error("Couldn't get hostname: %m");
die(1);
}
hostname[MAXNAMELEN-1] = 0;
hostname[sizeof(hostname) - 1] = 0;
uid = getuid();
privileged = uid == 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.23 1998/05/02 14:19:15 christos Exp $ */
/* $NetBSD: options.c,v 1.24 1998/07/06 07:04:29 mrg Exp $ */
/*
* options.c - handles option processing for PPP.
@ -24,7 +24,7 @@
#if 0
static char rcsid[] = "Id: options.c,v 1.42 1998/03/26 04:46:06 paulus Exp ";
#else
__RCSID("$NetBSD: options.c,v 1.23 1998/05/02 14:19:15 christos Exp $");
__RCSID("$NetBSD: options.c,v 1.24 1998/07/06 07:04:29 mrg Exp $");
#endif
#endif
@ -1578,7 +1578,8 @@ setdomain(argv)
option_error("using the domain option requires root privilege");
return 0;
}
gethostname(hostname, MAXNAMELEN);
gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname) - 1] = '\0';
if (**argv != 0) {
if (**argv != '.')
strncat(hostname, ".", MAXNAMELEN - strlen(hostname));

View File

@ -1,4 +1,4 @@
/* $NetBSD: pppd.h,v 1.12 1998/05/02 14:19:16 christos Exp $ */
/* $NetBSD: pppd.h,v 1.13 1998/07/06 07:04:29 mrg Exp $ */
/*
* pppd.h - PPP daemon global declarations.
@ -50,7 +50,11 @@
#define NUM_PPP 1 /* One PPP interface supported (per process) */
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
#define MAXARGS 1 /* max # args to a command */
#ifdef MAXHOSTNAMELEN
#define MAXNAMELEN MAXHOSTNAMELEN /* max length of hostname or name for auth */
#else
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
#endif
#define MAXSECRETLEN 256 /* max length of password or secret */
/*
@ -61,7 +65,7 @@ extern int hungup; /* Physical layer has disconnected */
extern int ifunit; /* Interface unit number */
extern char ifname[]; /* Interface name */
extern int ttyfd; /* Serial device file descriptor */
extern char hostname[]; /* Our hostname */
extern char hostname[MAXNAMELEN+1]; /* Our hostname */
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
extern int phase; /* Current state of link - see values below */
extern int baud_rate; /* Current link speed in bits/sec */

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.5 1995/10/06 05:12:14 thorpej Exp $ */
/* $NetBSD: defs.h,v 1.6 1998/07/06 06:57:52 mrg Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
@ -128,7 +128,7 @@ typedef struct rmpconn_s {
/*
* All these variables are defined in "conf.c".
*/
extern char MyHost[]; /* this hosts' name */
extern char MyHost[MAXHOSTNAMELEN+1]; /* this hosts' name */
extern pid_t MyPid; /* this processes' ID */
extern int DebugFlg; /* set true if debugging */
extern int BootAny; /* set true if we can boot anyone */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rbootd.c,v 1.8 1997/10/18 11:23:10 lukem Exp $ */
/* $NetBSD: rbootd.c,v 1.9 1998/07/06 06:57:52 mrg Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
@ -57,7 +57,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: rbootd.c,v 1.8 1997/10/18 11:23:10 lukem Exp $");
__RCSID("$NetBSD: rbootd.c,v 1.9 1998/07/06 06:57:52 mrg Exp $");
#endif
#endif /* not lint */
@ -171,11 +171,11 @@ main(argc, argv)
/*
* Grab our host name and pid.
*/
if (gethostname(MyHost, MAXHOSTNAMELEN) < 0) {
if (gethostname(MyHost, sizeof MyHost) < 0) {
syslog(LOG_ERR, "gethostname: %m");
Exit(0);
}
MyHost[MAXHOSTNAMELEN] = '\0';
MyHost[sizeof(MyHost) - 1] = '\0';
MyPid = getpid();

View File

@ -1,4 +1,4 @@
/* $NetBSD: statd.c,v 1.11 1998/06/22 20:40:01 tron Exp $ */
/* $NetBSD: statd.c,v 1.12 1998/07/06 06:58:09 mrg Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@ -37,14 +37,15 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: statd.c,v 1.11 1998/06/22 20:40:01 tron Exp $");
__RCSID("$NetBSD: statd.c,v 1.12 1998/07/06 06:58:09 mrg Exp $");
#endif
/* main() function for status monitor daemon. Some of the code in this */
/* file was generated by running rpcgen /usr/include/rpcsvc/sm_inter.x */
/* The actual program logic is in the file procs.c */
#include <sys/param.h>
#include <err.h>
#include <ctype.h>
#include <errno.h>
@ -588,9 +589,10 @@ notify_one_host(hostname)
CLIENT *cli;
char dummy;
stat_chge arg;
char our_hostname[SM_MAXSTRLEN + 1];
char our_hostname[MAXHOSTNAMELEN + 1];
gethostname(our_hostname, sizeof(our_hostname));
our_hostname[sizeof(our_hostname) - 1] = '\0';
our_hostname[SM_MAXSTRLEN] = '\0';
arg.mon_name = our_hostname;
arg.state = status_info.ourState;

View File

@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)rwhod.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: rwhod.c,v 1.12 1997/10/18 11:37:10 lukem Exp $");
__RCSID("$NetBSD: rwhod.c,v 1.13 1998/07/06 06:58:26 mrg Exp $");
#endif
#endif /* not lint */
@ -78,7 +78,7 @@ __RCSID("$NetBSD: rwhod.c,v 1.12 1997/10/18 11:37:10 lukem Exp $");
*/
#define AL_INTERVAL (3 * 60)
char myname[MAXHOSTNAMELEN];
char myname[MAXHOSTNAMELEN + 1];
/*
* We communicate with each neighbor in a list constructed at the time we're
@ -144,6 +144,7 @@ main(argc, argv)
syslog(LOG_ERR, "gethostname: %m");
exit(1);
}
myname[sizeof(myname) - 1] = '\0';
if ((cp = strchr(myname, '.')) != NULL)
*cp = '\0';
strncpy(mywd.wd_hostname, myname, sizeof(myname) - 1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: daemon.c,v 1.23 1998/01/09 08:11:06 perry Exp $ */
/* $NetBSD: daemon.c,v 1.24 1998/07/06 07:05:14 mrg Exp $ */
/*
* Copyright (c) 1983, 1995-1997 Eric P. Allman
@ -1130,6 +1130,7 @@ myhostname(hostbuf, size)
{
(void) strcpy(hostbuf, "localhost");
}
hostbuf[size - 1] = '\0';
hp = sm_gethostbyname(hostbuf);
if (hp == NULL)
return NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: map.c,v 1.17 1998/01/09 08:11:17 perry Exp $ */
/* $NetBSD: map.c,v 1.18 1998/07/06 07:05:14 mrg Exp $ */
/*
* Copyright (c) 1992, 1995-1997 Eric P. Allman.
@ -1141,6 +1141,7 @@ ndbm_map_close(map)
ndbm_map_store(map, "YP_LAST_MODIFIED", buf);
(void) gethostname(buf, sizeof buf);
buf[sizeof(buf) - 1] = '\0';
ndbm_map_store(map, "YP_MASTER_NAME", buf);
map->map_mflags = save_mflags;

View File

@ -1,4 +1,4 @@
/* $NetBSD: scm.c,v 1.6 1997/06/17 21:38:24 christos Exp $ */
/* $NetBSD: scm.c,v 1.7 1998/07/06 07:05:48 mrg Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -434,12 +434,12 @@ static
char *myhost () /* find my host name */
{
struct hostent *h;
static char name[MAXHOSTNAMELEN];
static char name[MAXHOSTNAMELEN + 1];
if (name[0] == '\0') {
if (gethostname (name,MAXHOSTNAMELEN) < 0)
if (gethostname(name, sizeof name) < 0)
return (NULL);
name[sizeof(name) - 1] = '\0';
if ((h = gethostbyname (name)) == NULL)
return (NULL);
(void) strcpy (name,h->h_name);

View File

@ -1,4 +1,4 @@
/* $NetBSD: supscan.c,v 1.6 1997/08/04 22:03:52 christos Exp $ */
/* $NetBSD: supscan.c,v 1.7 1998/07/06 07:05:48 mrg Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -121,7 +121,7 @@
#include <varargs.h>
#endif
#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
#include "supcdefs.h"
#include "supextern.h"
@ -408,7 +408,7 @@ va_dcl
int localhost (host)
register char *host;
{
static char myhost[STRINGLENGTH];
static char myhost[MAXHOSTNAMELEN + 1];
static int myhostlen;
register int hostlen;
@ -420,6 +420,7 @@ register char *host;
if (gethostname (myhost,sizeof (myhost)) < 0) {
quit (1,"supscan: can't get kernel host name\n");
}
myhost[sizeof(myhost) - 1] = '\0';
myhostlen = strlen(myhost);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysent.h,v 1.2 1997/06/17 18:57:06 christos Exp $ */
/* $NetBSD: sysent.h,v 1.3 1998/07/06 07:05:48 mrg Exp $ */
/*
* Copyright (c) 1991 Carnegie Mellon University
@ -77,7 +77,7 @@ extern gid_t getegid(void);
extern int getgroups(int, int *);
extern long gethostid(void);
extern int sethostid(long);
extern int gethostname(char *, int);
extern int gethostname(char *, size_t);
extern int sethostname(const char *, int);
extern int getpagesize(void);
extern int getpgrp(int);

View File

@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
#else
__RCSID("$NetBSD: syslogd.c,v 1.18 1998/05/08 19:03:41 kleink Exp $");
__RCSID("$NetBSD: syslogd.c,v 1.19 1998/07/06 06:58:44 mrg Exp $");
#endif
#endif /* not lint */
@ -254,6 +254,7 @@ main(argc, argv)
consfile.f_type = F_CONSOLE;
(void)strcpy(consfile.f_un.f_fname, ctty);
(void)gethostname(LocalHostName, sizeof(LocalHostName));
LocalHostName[sizeof(LocalHostName) - 1] = '\0';
if ((p = strchr(LocalHostName, '.')) != NULL) {
*p++ = '\0';
LocalDomain = p;

View File

@ -1,4 +1,4 @@
/* $NetBSD: timed.c,v 1.9 1997/10/17 14:19:48 lukem Exp $ */
/* $NetBSD: timed.c,v 1.10 1998/07/06 07:06:13 mrg Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -44,12 +44,12 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)timed.c 8.2 (Berkeley) 3/26/95";
#else
__RCSID("$NetBSD: timed.c,v 1.9 1997/10/17 14:19:48 lukem Exp $");
__RCSID("$NetBSD: timed.c,v 1.10 1998/07/06 07:06:13 mrg Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.9 $"
#ident "$Revision: 1.10 $"
#endif /* sgi */
#define TSPTYPES
@ -297,10 +297,11 @@ main(int argc, char **argv)
if (0 != goodgroup || 0 != goodhosts)
Mflag = 1;
if (gethostname(hostname, sizeof(hostname) - 1) < 0) {
if (gethostname(hostname, sizeof(hostname)) < 0) {
perror("gethostname");
exit(1);
}
hostname[sizeof(hostname) - 1] = '\0';
self.l_bak = &self;
self.l_fwd = &self;
self.h_bak = &self;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmds.c,v 1.8 1997/10/18 07:13:33 lukem Exp $ */
/* $NetBSD: cmds.c,v 1.9 1998/07/06 07:06:14 mrg Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@ -38,12 +38,12 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 3/26/95";
#else
__RCSID("$NetBSD: cmds.c,v 1.8 1997/10/18 07:13:33 lukem Exp $");
__RCSID("$NetBSD: cmds.c,v 1.9 1998/07/06 07:06:14 mrg Exp $");
#endif
#endif /* not lint */
#ifdef sgi
#ident "$Revision: 1.8 $"
#ident "$Revision: 1.9 $"
#endif
#include "timedc.h"
@ -74,7 +74,7 @@ __RCSID("$NetBSD: cmds.c,v 1.8 1997/10/18 07:13:33 lukem Exp $");
int sock;
int sock_raw;
char myname[MAXHOSTNAMELEN];
char myname[MAXHOSTNAMELEN + 1];
struct hostent *hp;
struct sockaddr_in server;
struct sockaddr_in dayaddr;
@ -192,6 +192,7 @@ clockdiff(argc, argv)
}
(void)gethostname(myname,sizeof(myname));
myname[sizeof(myname) - 1] = '\0';
/* get the address for the date ready */
sp = getservbyname(DATE_PORT, DATE_PROTO);

View File

@ -1,4 +1,4 @@
/* $NetBSD: traceroute.c,v 1.22 1998/07/04 20:47:24 mrg Exp $ */
/* $NetBSD: traceroute.c,v 1.23 1998/07/06 06:59:06 mrg Exp $ */
/*
* Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997
@ -29,7 +29,7 @@ static const char rcsid[] =
#else
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997\n\
The Regents of the University of California. All rights reserved.\n");
__RCSID("$NetBSD: traceroute.c,v 1.22 1998/07/04 20:47:24 mrg Exp $");
__RCSID("$NetBSD: traceroute.c,v 1.23 1998/07/06 06:59:06 mrg Exp $");
#endif
#endif
@ -1211,11 +1211,13 @@ inetname(struct in_addr in)
static char domain[MAXHOSTNAMELEN + 1], line[MAXHOSTNAMELEN + 1];
if (first && !nflag) {
int rv;
first = 0;
if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
(cp = strchr(domain, '.')) != NULL) {
rv = gethostname(domain, sizeof domain);
domain[sizeof(domain) - 1] = '\0';
if (rv == 0 && (cp = strchr(domain, '.')) != NULL) {
(void)strncpy(domain, cp + 1, sizeof(domain) - 1);
domain[sizeof(domain) - 1] = '\0';
} else
domain[0] = '\0';
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: localhostname.c,v 1.5 1998/04/23 19:32:40 kleink Exp $ */
/* $NetBSD: localhostname.c,v 1.6 1998/07/06 07:06:39 mrg Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: localhostname.c,v 1.5 1998/04/23 19:32:40 kleink Exp $");
__RCSID("$NetBSD: localhostname.c,v 1.6 1998/07/06 07:06:39 mrg Exp $");
#endif
#include <sys/param.h>
@ -56,11 +56,12 @@ localhostname(buf, buflen)
size_t buflen;
{
struct hostent *hp;
char hostname[MAXHOSTNAMELEN];
char hostname[MAXHOSTNAMELEN + 1];
int i;
if (gethostname(hostname, sizeof(hostname)))
err(1, "gethostname");
hostname[sizeof(hostname) - 1] = '\0';
memset(buf, 0, buflen);