Skip to content

Commit

Permalink
Testing a possible fix for asn1time test
Browse files Browse the repository at this point in the history
  • Loading branch information
botovq committed May 25, 2024
1 parent bdb15f6 commit 4181f89
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions patches/asn1time.patch
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;
}

0 comments on commit 4181f89

Please sign in to comment.