From 5ce7f7bbb54913064b2974b611614bea2eff9998 Mon Sep 17 00:00:00 2001 From: bde Date: Mon, 29 Jun 1998 18:09:59 +0000 Subject: [PATCH] Don't assume that time_t is long. --- usr.sbin/timed/timed/master.c | 9 ++++++--- usr.sbin/timed/timed/readmsg.c | 6 ++++-- usr.sbin/timed/timed/slave.c | 12 ++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/usr.sbin/timed/timed/master.c b/usr.sbin/timed/timed/master.c index 14dc6d1f4f2b..c6b399b48dbf 100644 --- a/usr.sbin/timed/timed/master.c +++ b/usr.sbin/timed/timed/master.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)master.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: master.c,v 1.3 1997/10/22 06:19:48 charnier Exp $"; + "$Id: master.c,v 1.4 1997/10/29 07:32:28 charnier Exp $"; #endif /* not lint */ #include "globals.h" @@ -83,6 +83,7 @@ master() #define POLLRATE 4 int polls; struct timeval wait, ntime; + time_t tsp_time_sec; struct tsp *msg, *answer, to; char newdate[32]; struct sockaddr_in taddr; @@ -179,7 +180,8 @@ master() #ifdef sgi (void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec); #else - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + tsp_time_sec = msg->tsp_time.tv_sec; + (void)strcpy(newdate, ctime(&tsp_time_sec)); #endif /* sgi */ if (!good_host_name(msg->tsp_name)) { syslog(LOG_NOTICE, @@ -200,7 +202,8 @@ master() #ifdef sgi (void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec); #else - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + tsp_time_sec = msg->tsp_time.tv_sec; + (void)strcpy(newdate, ctime(&tsp_time_sec)); #endif /* sgi */ htp = findhost(msg->tsp_name); if (htp == 0) { diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c index 580bbbf0ad98..6ea691069b0a 100644 --- a/usr.sbin/timed/timed/readmsg.c +++ b/usr.sbin/timed/timed/readmsg.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)readmsg.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: readmsg.c,v 1.2 1997/10/22 06:19:48 charnier Exp $"; + "$Id: readmsg.c,v 1.3 1997/10/29 07:32:29 charnier Exp $"; #endif /* not lint */ #include "globals.h" @@ -435,6 +435,7 @@ print(msg, addr) struct sockaddr_in *addr; { char tm[26]; + time_t tsp_time_sec; switch (msg->tsp_type) { case TSP_LOOP: @@ -453,7 +454,8 @@ print(msg, addr) #ifdef sgi (void)cftime(tm, "%D %T", &msg->tsp_time.tv_sec); #else - strncpy(tm, ctime(&msg->tsp_time.tv_sec)+3+1, sizeof(tm)); + tsp_time_sec = msg->tsp_time.tv_sec; + strncpy(tm, ctime(&tsp_time_sec)+3+1, sizeof(tm)); tm[15] = '\0'; /* ugh */ #endif /* sgi */ fprintf(fd, "%s %d %-6u %s %-15s %s\n", diff --git a/usr.sbin/timed/timed/slave.c b/usr.sbin/timed/timed/slave.c index bab9bcd22adb..82551f6b6dd6 100644 --- a/usr.sbin/timed/timed/slave.c +++ b/usr.sbin/timed/timed/slave.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: slave.c,v 1.4 1997/10/29 07:32:29 charnier Exp $"; + "$Id: slave.c,v 1.5 1997/10/31 12:33:06 charnier Exp $"; #endif /* not lint */ #include "globals.h" @@ -77,6 +77,7 @@ slave() char tname[MAXHOSTNAMELEN]; struct tsp *msg, to; struct timeval ntime, wait; + time_t tsp_time_sec; struct tsp *answer; int timeout(); char olddate[32]; @@ -266,7 +267,8 @@ slave() * calling ctime() which clobbers the static buffer */ (void)strcpy(olddate, date()); - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + tsp_time_sec = msg->tsp_time.tv_sec; + (void)strcpy(newdate, ctime(&tsp_time_sec)); #endif /* sgi */ if (!good_host_name(msg->tsp_name)) { @@ -357,7 +359,8 @@ slave() #ifdef sgi (void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec); #else - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + tsp_time_sec = msg->tsp_time.tv_sec; + (void)strcpy(newdate, ctime(&tsp_time_sec)); #endif /* sgi */ schgdate(msg, newdate); break; @@ -368,7 +371,8 @@ slave() #ifdef sgi (void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec); #else - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + tsp_time_sec = msg->tsp_time.tv_sec; + (void)strcpy(newdate, ctime(&tsp_time_sec)); #endif /* sgi */ htp = findhost(msg->tsp_name); if (0 == htp) {