[ntp:bk-ntp-dev-send] BitKeeper diffs

Harlan Stenn stenn at deacon.udel.edu
Thu Apr 7 05:58:19 UTC 2011


#### ChangeSet ####
2011-04-05 19:23:34+02:00, jnperlin at hydra.localnet
  [bug 1875] 'asn2ntp()' rewritten in terms of 'caltontp()' (ChangeLog update)

==== ChangeLog ====
2011-04-05 19:23:34+02:00, jnperlin at hydra.localnet +2 -0
  [bug 1875] 'asn2ntp()' rewritten in terms of 'caltontp()'

--- 1.832/ChangeLog	2011-04-04 07:43:49 -04:00
+++ 1.832.1.1/ChangeLog	2011-04-05 13:23:34 -04:00
@@ -1,3 +1,5 @@
+* [Bug 1875] 'asn2ntp()' rewritten with 'caltontp()'; 'timegm()'
+  substitute likely to crash with 64bit time_t.
 (4.2.7p145) 2011/04/04 Released by Harlan Stenn <stenn at ntp.org>
 * [Bug 1840] ntp_lists.h FIFO macros buggy.
 (4.2.7p144) 2011/04/03 Released by Harlan Stenn <stenn at ntp.org>

#### ChangeSet ####
2011-04-04 18:39:05+02:00, jnperlin at hydra.localnet
  bug1875 added missing header

==== ntpd/ntp_crypto.c ====
2011-04-04 18:39:05+02:00, jnperlin at hydra.localnet +1 -0
  added missing header

--- 1.156/ntpd/ntp_crypto.c	2011-04-04 12:37:14 -04:00
+++ 1.157/ntpd/ntp_crypto.c	2011-04-04 12:39:05 -04:00
@@ -18,6 +18,7 @@
 #include "ntp_string.h"
 #include "ntp_random.h"
 #include "ntp_assert.h"
+#include "ntp_calendar.h"
 
 #include "openssl/asn1_mac.h"
 #include "openssl/bn.h"

#### ChangeSet ####
2011-04-04 18:37:14+02:00, jnperlin at hydra.localnet
  bug1875: timegm() from libntp blows up with 64bit time_t on Windows

==== ntpd/ntp_crypto.c ====
2011-04-04 18:37:14+02:00, jnperlin at hydra.localnet +14 -13
  bug1875: timegm() from libntp blows up with 64bit time_t on Windows

--- 1.155/ntpd/ntp_crypto.c	2011-03-29 09:35:10 -04:00
+++ 1.156/ntpd/ntp_crypto.c	2011-04-04 12:37:14 -04:00
@@ -1903,7 +1903,7 @@ asn2ntp	(
 	)
 {
 	char	*v;		/* pointer to ASN1_TIME string */
-	struct	tm tm;		/* used to convert to NTP time */
+	struct calendar jd;	/* used to convert to NTP time */
 
 	/*
 	 * Extract time string YYMMDDHHMMSSZ from ASN1 time structure.
@@ -1913,18 +1913,19 @@ asn2ntp	(
 	 * 100. Dontcha love ASN.1? Better than MIL-188.
 	 */
 	v = (char *)asn1time->data;
-	tm.tm_year = (v[0] - '0') * 10 + v[1] - '0';
-	if (tm.tm_year < 50)
-		tm.tm_year += 100;
-	tm.tm_mon = (v[2] - '0') * 10 + v[3] - '0' - 1;
-	tm.tm_mday = (v[4] - '0') * 10 + v[5] - '0';
-	tm.tm_hour = (v[6] - '0') * 10 + v[7] - '0';
-	tm.tm_min = (v[8] - '0') * 10 + v[9] - '0';
-	tm.tm_sec = (v[10] - '0') * 10 + v[11] - '0';
-	tm.tm_wday = 0;
-	tm.tm_yday = 0;
-	tm.tm_isdst = 0;
-	return ((u_long)timegm(&tm) + JAN_1970);
+	jd.year = (v[0] - '0') * 10 + v[1] - '0';
+	if (jd.year < 50)
+		jd.year += 100;
+	jd.year += 1900; /* should we do century unfolding here? */
+	jd.month = (v[2] - '0') * 10 + v[3] - '0';
+	jd.monthday = (v[4] - '0') * 10 + v[5] - '0';
+	jd.hour = (v[6] - '0') * 10 + v[7] - '0';
+	jd.minute = (v[8] - '0') * 10 + v[9] - '0';
+	jd.second = (v[10] - '0') * 10 + v[11] - '0';
+	jd.yearday = 0;
+	jd.weekday = 0;
+
+	return caltontp(&jd);
 }
 
 


More information about the bk-ntp-dev-send mailing list