summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authortg <tg@FreeBSD.org>1996-01-08 08:45:11 +0000
committertg <tg@FreeBSD.org>1996-01-08 08:45:11 +0000
commit3355d831f56f8569867e70690afff8f72a15d68f (patch)
tree0d4c2668ed71c241f3c229123709327f08455a3e /usr.sbin
parent709700e64dcc7979a5c56562f62229e28b5e5f17 (diff)
downloadFreeBSD-src-3355d831f56f8569867e70690afff8f72a15d68f.zip
FreeBSD-src-3355d831f56f8569867e70690afff8f72a15d68f.tar.gz
Fix leap year calculations in parse_to_unixtime()
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/xntpd/parse/parse.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/xntpd/parse/parse.c b/usr.sbin/xntpd/parse/parse.c
index 713d3e6..d283b66 100644
--- a/usr.sbin/xntpd/parse/parse.c
+++ b/usr.sbin/xntpd/parse/parse.c
@@ -605,7 +605,9 @@ parse_iodone(parseio)
/*
* convert a struct clock to UTC since Jan, 1st 1970 0:00 (the UNIX EPOCH)
*/
-#define dysize(x) ((x) % 4 ? 365 : ((x % 400) ? 365 :366))
+#define dysize(x) (((x) % 4) ? 365 : \
+ (((x) % 100) ? : 366 \
+ (((x) % 400) ? 365 : 366)))
time_t
parse_to_unixtime(clock, cvtrtc)
@@ -649,8 +651,8 @@ parse_to_unixtime(clock, cvtrtc)
return -1; /* bad month */
}
/* adjust leap year */
- if (clock->month >= 3 && dysize(clock->year) == 366)
- t++;
+ if (clock->month < 3 && dysize(clock->year) == 366)
+ t--;
for (i = 1; i < clock->month; i++)
{
OpenPOWER on IntegriCloud