summaryrefslogtreecommitdiff
path: root/usr.sbin/rwhod
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-09-16 08:55:01 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-09-16 08:55:01 +0000
commit35cf7201f237e00337a0d7b1a37dd6124697188a (patch)
treeafdcf10c43bbd6929c79f0d4fb5577957f58a9cb /usr.sbin/rwhod
parentba85288ecb902060dd45ab0ef56418e3516c8e87 (diff)
various lint. ok millert
Important bit: do not long -> int truncate...
Diffstat (limited to 'usr.sbin/rwhod')
-rw-r--r--usr.sbin/rwhod/rwhod.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c
index aab647fbe28..728ab2fe987 100644
--- a/usr.sbin/rwhod/rwhod.c
+++ b/usr.sbin/rwhod/rwhod.c
@@ -35,7 +35,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "@(#)rwhod.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: rwhod.c,v 1.29 2003/09/26 07:15:41 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: rwhod.c,v 1.30 2004/09/16 08:55:00 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -98,7 +98,7 @@ volatile sig_atomic_t gothup;
#define WHDRSIZE (sizeof(mywd) - sizeof(mywd.wd_we))
-int configure(int);
+int configure(void);
void getboottime(void);
void hup(int);
void timer(void);
@@ -110,6 +110,7 @@ int Sendto(int, const void *, size_t, int, const struct sockaddr *,
socklen_t);
char *interval(int, char *);
+/* ARGSUSED */
void
hup(int signo)
{
@@ -188,7 +189,7 @@ main(int argc, char *argv[])
syslog(LOG_ERR, "bind: %m");
exit(1);
}
- if (!configure(s))
+ if (!configure())
exit(1);
timer();
@@ -293,7 +294,7 @@ handleread(int s)
(void) time((time_t *)&wd.wd_recvtime);
(void) write(whod, (char *)&wd, cc);
if (fstat(whod, &st) < 0 || st.st_size > cc)
- ftruncate(whod, cc);
+ ftruncate(whod, (off_t)cc);
(void) close(whod);
}
@@ -352,6 +353,11 @@ timer(void)
getboottime();
alarmcount++;
(void) fstat(utmpf, &stb);
+
+ /* implicitly safe truncation */
+ if (stb.st_size > 1024*1024 * sizeof(struct utmp))
+ stb.st_size = 1024*1024 * sizeof(struct utmp);
+
if ((stb.st_mtime != utmptime) || (stb.st_size > utmpsize)) {
utmptime = stb.st_mtime;
if (stb.st_size > utmpsize) {
@@ -367,7 +373,7 @@ timer(void)
utmpsize = nutmpsize;
}
(void) lseek(utmpf, (off_t)0, SEEK_SET);
- cc = read(utmpf, (char *)utmp, stb.st_size);
+ cc = read(utmpf, (char *)utmp, (size_t)stb.st_size);
if (cc < 0) {
warnx("%s", _PATH_UTMP);
return;
@@ -466,7 +472,7 @@ rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo)
* networks which deserve status information.
*/
int
-configure(int s)
+configure(void)
{
struct neighbor *np;
struct if_msghdr *ifm;
@@ -507,7 +513,7 @@ configure(int s)
ifam = (struct ifa_msghdr *)ifm;
info.rti_addrs = ifam->ifam_addrs;
rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam,
- &info);
+ &info);
/* gag, wish we could get rid of Internet dependencies */
#define dstaddr info.rti_info[RTAX_BRD]
#define IPADDR_SA(x) ((struct sockaddr_in *)(x))->sin_addr.s_addr