From e90fa6a9379dbf72fb237bd9865975231a57c287 Mon Sep 17 00:00:00 2001 From: David Malone Date: Mon, 17 Apr 2006 18:35:58 +0000 Subject: [PATCH] Port 37 (RFC 738) style times are supposed to be a 32 bit time since 1900 in network byte order. Use a uint32_t to calculate and send the time, so that we don't need to know how big ints or longs are. I used uint32_t instead of int in the patch, on the off chance someone uses our inetd source on a system that doesnt 32 bit ints. PR: 95290 Submitted by: Bruce Becker MFC after: 2 weeks --- usr.sbin/inetd/Makefile | 2 +- usr.sbin/inetd/builtins.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/usr.sbin/inetd/Makefile b/usr.sbin/inetd/Makefile index afe4c511358..7e554a6a6e1 100644 --- a/usr.sbin/inetd/Makefile +++ b/usr.sbin/inetd/Makefile @@ -7,7 +7,7 @@ MLINKS= inetd.8 inetd.conf.5 SRCS= inetd.c builtins.c WARNS?= 2 -CFLAGS+= -DLOGIN_CAP +CFLAGS+= -DLOGIN_CAP -fno-builtin #CFLAGS+= -DSANITY_CHECK DPADD= ${LIBUTIL} ${LIBWRAP} diff --git a/usr.sbin/inetd/builtins.c b/usr.sbin/inetd/builtins.c index 96eeb3357fa..e6ef6759b6e 100644 --- a/usr.sbin/inetd/builtins.c +++ b/usr.sbin/inetd/builtins.c @@ -64,7 +64,7 @@ static int getline(int, char *, int); void iderror(int, int, int, const char *); void ident_stream(int, struct servtab *); void initring(void); -unsigned long machtime(void); +uint32_t machtime(void); void machtime_dg(int, struct servtab *); void machtime_stream(int, struct servtab *); @@ -685,7 +685,7 @@ printit: * some seventy years Bell Labs was asleep. */ -unsigned long +uint32_t machtime(void) { struct timeval tv; @@ -695,8 +695,8 @@ machtime(void) warnx("unable to get time of day"); return (0L); } -#define OFFSET ((u_long)25567 * 24*60*60) - return (htonl((long)(tv.tv_sec + OFFSET))); +#define OFFSET ((uint32_t)25567 * 24*60*60) + return (htonl((uint32_t)(tv.tv_sec + OFFSET))); #undef OFFSET } @@ -704,7 +704,7 @@ machtime(void) void machtime_dg(int s, struct servtab *sep) { - unsigned long result; + uint32_t result; struct sockaddr_storage ss; socklen_t size; @@ -725,7 +725,7 @@ machtime_dg(int s, struct servtab *sep) void machtime_stream(int s, struct servtab *sep __unused) { - unsigned long result; + uint32_t result; result = machtime(); (void) send(s, (char *) &result, sizeof(result), MSG_EOF);