From 1b7ac57ccea5e902a5153d8337c8476912eba485 Mon Sep 17 00:00:00 2001 From: Mike Pechkin Date: Tue, 19 Feb 2002 18:38:03 +0000 Subject: Fix gethostname() usage. deraadt@ ok --- usr.sbin/cron/do_command.c | 6 +++--- usr.sbin/rbootd/conf.c | 6 +++--- usr.sbin/rbootd/rbootd.c | 6 +++--- usr.sbin/timed/timed/timed.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index 5f5d1c88b49..e445e95af04 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: do_command.c,v 1.12 2002/01/09 00:51:00 millert Exp $ */ +/* $OpenBSD: do_command.c,v 1.13 2002/02/19 18:38:02 mpech Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved */ @@ -21,7 +21,7 @@ */ #if !defined(lint) && !defined(LINT) -static char rcsid[] = "$OpenBSD: do_command.c,v 1.12 2002/01/09 00:51:00 millert Exp $"; +static char rcsid[] = "$OpenBSD: do_command.c,v 1.13 2002/02/19 18:38:02 mpech Exp $"; #endif #include "cron.h" @@ -396,7 +396,7 @@ child_process(entry *e, user *u) { char mailcmd[MAX_COMMAND]; char hostname[MAXHOSTNAMELEN]; - gethostname(hostname, MAXHOSTNAMELEN); + gethostname(hostname, sizeof(hostname)); if (snprintf(mailcmd, sizeof mailcmd, MAILFMT, MAILARG) >= sizeof mailcmd) { fprintf(stderr, "mailcmd too long\n"); diff --git a/usr.sbin/rbootd/conf.c b/usr.sbin/rbootd/conf.c index c504c16a348..3a7d334826a 100644 --- a/usr.sbin/rbootd/conf.c +++ b/usr.sbin/rbootd/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.3 2001/12/01 23:27:23 miod Exp $ */ +/* $OpenBSD: conf.c,v 1.4 2002/02/19 18:38:02 mpech Exp $ */ /* $NetBSD: conf.c,v 1.5 1995/10/06 05:12:13 thorpej Exp $ */ /* @@ -49,7 +49,7 @@ #ifndef lint /*static char sccsid[] = "@(#)conf.c 8.1 (Berkeley) 6/4/93";*/ -static char rcsid[] = "$OpenBSD: conf.c,v 1.3 2001/12/01 23:27:23 miod Exp $"; +static char rcsid[] = "$OpenBSD: conf.c,v 1.4 2002/02/19 18:38:02 mpech Exp $"; #endif /* not lint */ #include @@ -69,7 +69,7 @@ static char rcsid[] = "$OpenBSD: conf.c,v 1.3 2001/12/01 23:27:23 miod Exp $"; ** simplify the boot file search code. */ -char MyHost[MAXHOSTNAMELEN+1]; /* host name */ +char MyHost[MAXHOSTNAMELEN]; /* host name */ int DebugFlg = 0; /* set true if debugging */ int BootAny = 0; /* set true if we boot anyone */ diff --git a/usr.sbin/rbootd/rbootd.c b/usr.sbin/rbootd/rbootd.c index 6492d0c15f6..ce990cebcdd 100644 --- a/usr.sbin/rbootd/rbootd.c +++ b/usr.sbin/rbootd/rbootd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rbootd.c,v 1.9 2001/12/01 23:27:23 miod Exp $ */ +/* $OpenBSD: rbootd.c,v 1.10 2002/02/19 18:38:02 mpech Exp $ */ /* $NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $ */ /* @@ -55,7 +55,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";*/ -static char rcsid[] = "$OpenBSD: rbootd.c,v 1.9 2001/12/01 23:27:23 miod Exp $"; +static char rcsid[] = "$OpenBSD: rbootd.c,v 1.10 2002/02/19 18:38:02 mpech Exp $"; #endif /* not lint */ #include @@ -168,7 +168,7 @@ 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); } diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c index a843c718ec9..6a78ff01011 100644 --- a/usr.sbin/timed/timed/timed.c +++ b/usr.sbin/timed/timed/timed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timed.c,v 1.11 2001/11/23 03:45:51 deraadt Exp $ */ +/* $OpenBSD: timed.c,v 1.12 2002/02/19 18:38:02 mpech Exp $ */ /*- * Copyright (c) 1985, 1993 The Regents of the University of California. @@ -44,7 +44,7 @@ static char sccsid[] = "@(#)timed.c 5.1 (Berkeley) 5/11/93"; #endif /* not lint */ #ifdef sgi -#ident "$Revision: 1.11 $" +#ident "$Revision: 1.12 $" #endif /* sgi */ #define TSPTYPES @@ -298,7 +298,7 @@ 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); } -- cgit v1.2.3