Skip to content

Commit ead57c3

Browse files
davidbenBoringssl LUCI CQ
authored and
Boringssl LUCI CQ
committed
Reject years outside 0000-9999 in ASN1_GENERALIZEDTIME_adj.
They would previously output syntax errors. Change-Id: I7817a91d0c8ed8d6ac6a5a1fd9c9ed1223c5960e Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/48667 Commit-Queue: David Benjamin <[email protected]> Reviewed-by: Adam Langley <[email protected]>
1 parent 46e0523 commit ead57c3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

crypto/asn1/a_gentm.c

+5
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
237237
goto err;
238238
}
239239

240+
if (ts->tm_year < 0 - 1900 || ts->tm_year > 9999 - 1900) {
241+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_TIME_VALUE);
242+
goto err;
243+
}
244+
240245
p = (char *)tmps->data;
241246
if ((p == NULL) || ((size_t)tmps->length < len)) {
242247
p = OPENSSL_malloc(len);

crypto/asn1/asn1_test.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,11 @@ TEST(ASN1Test, SetTime) {
478478
// disable the tests on 32-bit. Re-enable them once the bug is fixed.
479479
{2524607999, "20491231235959Z", "491231235959Z"},
480480
{2524608000, "20500101000000Z", nullptr},
481-
// TODO(davidben): Fix and then test boundary conditions for GeneralizedTime
482-
// years.
481+
// Test boundary conditions.
482+
{-62167219200, "00000101000000Z", nullptr},
483+
{-62167219201, nullptr, nullptr},
484+
{253402300799, "99991231235959Z", nullptr},
485+
{253402300800, nullptr, nullptr},
483486
#endif
484487
};
485488
for (const auto &t : kTests) {

0 commit comments

Comments
 (0)