-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Op 24-12-11 00:29, Miek Gieben schreef: > [ Quoting <[email protected]> at 00:17 on Dec 24 in "Re: > [ldns-users] Bug..." ] >> Index: util.c >> =================================================================== >> >> - --- util.c (revision 3625) >> +++ util.c (working copy) @@ -256,10 +256,7 @@ int new_year; >> >> while (days < 0 || days >= (int64_t) (is_leap_year(year) ? 366 : >> 365)) { - new_year = year + (int) LDNS_DIV(days, 366); - >> if >> (year == new_year) { - year += days < 0 ? -1 : 1; - >> } + >> new_year = year + (int) LDNS_DIV(days, 365); days -= (new_year - >> year) * 365; days -= leap_days(year, new_year); year = >> new_year; > > Looks OK. I can ask Tom to apply it locally and test it a little? > (don't know if he's also on this list)
I just subscribed to the openddnssec-user list (also in To:). I used the attached brute force test program (for 32 bits systems). I've also compared the result of ldns_gmtime64_r and gmtime_r for a broader range of values on a 64 bits system, but since ldns_gmtime64_r is local to util.c I have no ``external'' test program. The fix with replacing >= with > still produces some mismatches.. Sorry about all this. I think it somehow slipped in in earlier attempts (before LDNS_DIV and LDNS_MOD) to compensate for C's behaviour of the % and / operators for negative numbers (which is undefined b.t.w.). - -- willem -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJO9RTBAAoJEOX4+CEvd6SY/RAP/3JCGj7jcVHTuu48W+ZIjC3j 3WJ5DvkliY2w3HBjqNz3CWS6OpG106D2tsP9+HGDCpam0xzIvBEMyxshpSmA2+9d ceFXmTB45/cT91krqEIsAmgffndJDkL+1ESOd9OOZIuF2dC21g1KrygUK+Jz69BN dTFbyIHGn2G6wUs9jNyfGHY5XmZYKrlWjpLQykXqLALv5rz4j1X7AHtJOlikrOnt HL+UzA+EwSjpqYB+CFtc/Kkw/+OzUrB1q1mb4ZD8Pp7G42oKNIcZlOrQKhk/WrKb 9W4IqaC4v5noK300quW2CsiCuNhJ8a+ni4YulQUHkY3eOegTiQm8kiSQV0Ubfw2r PFduhsXWBcB4Q9lznRw10N5Jap4muUM5e22mt9RKemJvurvU0Do7VHKiofIiWrI4 ya2rX7MEVeJ9JsVz6KXs868qvrxAqGjA/JbRc340W8TFcTqdnGa+xIJpwqaHcT1M zPWenIa3xX3V8zVGhgt8FLtww+ybRLzu5yr9+Lbu17JDzf6ZAvKtEPUjji485lLz hN6QjHfBSot9Yq9xma05Xrd0RYrbwzYsVGVSuOVFOgPKYHcZznpSUC4MYWNY59JE DAFHf4PcvKhajcsZC0ZjelKMZdvImUZA2mlEO3G8fxky8bRBnce2v3fRSLiW1jXc IErEh6n5cEgc/fUtLi2J =wGzW -----END PGP SIGNATURE-----
#include <ldns/util.h>
#include <stdio.h>
#include <stdint.h>
int main()
{
int32_t test_time;
time_t test_time_as_time_t;
struct tm tm_ldns;
struct tm tm_sys;
int ret_val = 0;
test_time = -2145916800;
while (test_time <= 2145916800) {
test_time_as_time_t = (time_t) test_time;
ldns_serial_arithmitics_gmtime_r(test_time, 0, &tm_ldns);
gmtime_r(&test_time_as_time_t, &tm_sys);
if (tm_ldns.tm_yday != tm_sys.tm_yday
|| tm_ldns.tm_wday != tm_sys.tm_wday
|| tm_ldns.tm_year != tm_sys.tm_year
|| tm_ldns.tm_mon != tm_sys.tm_mon
|| tm_ldns.tm_mday != tm_sys.tm_mday
|| tm_ldns.tm_hour != tm_sys.tm_hour
|| tm_ldns.tm_min != tm_sys.tm_min
|| tm_ldns.tm_sec != tm_sys.tm_sec) {
printf("%11d ", test_time);
printf( "sys : %d-%d-%d %.2d:%.2d.%.2d\n"
, tm_sys.tm_year + 1900, tm_sys.tm_mon
, tm_sys.tm_mday , tm_sys.tm_hour
, tm_sys.tm_min , tm_sys.tm_sec
);
printf("%11s ", "");
printf( "ldns: %d-%d-%d %.2d:%.2d.%.2d\n"
, tm_ldns.tm_year + 1900, tm_ldns.tm_mon
, tm_ldns.tm_mday , tm_ldns.tm_hour
, tm_ldns.tm_min , tm_ldns.tm_sec
);
ret_val |= -1;
}
test_time += 24 * 60 * 60;
}
return ret_val;
}
ldns_year_and_yday_from_days_since_epoch_test.c.sig
Description: Binary data
_______________________________________________ Opendnssec-user mailing list [email protected] https://lists.opendnssec.org/mailman/listinfo/opendnssec-user
