-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing a possible fix for asn1time test
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
This should be committed to base if the previous two commits work | ||
|
||
--- tests/asn1time.c.orig Sat May 25 20:17:32 2024 | ||
+++ tests/asn1time.c Sat May 25 20:24:47 2024 | ||
@@ -121,6 +121,18 @@ static const struct asn1_time_test asn1_gentime_tests[ | ||
0x5a, | ||
}, | ||
}, | ||
+ { | ||
+ /* 1 second after the epoch wraps. */ | ||
+ .str = "20380119031408Z", | ||
+ .data = "20380119031408Z", | ||
+ .time = 2147483648LL, | ||
+ .der = { | ||
+ 0x18, 0x0f, 0x32, 0x30, 0x33, 0x38, 0x30, 0x31, | ||
+ 0x31, 0x39, 0x30, 0x33, 0x31, 0x34, 0x30, 0x38, | ||
+ 0x5a, | ||
+ }, | ||
+ | ||
+ }, | ||
}; | ||
|
||
static const struct asn1_time_test asn1_utctime_tests[] = { | ||
@@ -280,6 +292,7 @@ asn1_gentime_test(int test_no, const struct asn1_time_ | ||
const unsigned char *der; | ||
unsigned char *p = NULL; | ||
ASN1_GENERALIZEDTIME *gt = NULL; | ||
+ time_t t; | ||
int failure = 1; | ||
int len; | ||
struct tm tm; | ||
@@ -307,11 +320,18 @@ asn1_gentime_test(int test_no, const struct asn1_time_ | ||
goto done; | ||
} | ||
|
||
- if (timegm(&tm) != att->time) { | ||
+ if (!OPENSSL_timegm(&tm, &t) || t != att->time) { | ||
/* things with crappy time_t should die in fire */ | ||
- int64_t a = timegm(&tm); | ||
- int64_t b = att->time; | ||
- fprintf(stderr, "FAIL: test %d - times don't match, expected %lld got %lld\n", | ||
+ int64_t a, b; | ||
+ | ||
+ if (!OPENSSL_tm_to_posix(&tm, &a)) { | ||
+ fprintf(stderr, "FAIL: test %d - " | ||
+ "OPENSSL_tm_to_posix() failed", test_no); | ||
+ goto done; | ||
+ } | ||
+ b = att->time; | ||
+ fprintf(stderr, "FAIL: test %d - times don't match, " | ||
+ "expected %lld got %lld\n", | ||
test_no, (long long)b, (long long)a); | ||
goto done; | ||
} |