-/* $OpenBSD: asn1time.c,v 1.22 2024/02/18 16:32:29 tb Exp $ */
+/* $OpenBSD: asn1time.c,v 1.23 2024/02/18 16:56:33 tb Exp $ */
/*
* Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
* Copyright (c) 2024 Google Inc.
asn1_time_overflow(void)
{
struct tm overflow_year = {0}, overflow_month = {0};
- struct tm copy, max_time = {0}, min_time = {0};
+ struct tm copy, max_time = {0}, min_time = {0}, zero = {0};
int64_t valid_time_range = INT64_C(315569519999);
int64_t posix_u64;
time_t posix_time;
"fail for maximum time\n");
goto err;
}
+ if (memcmp(&zero, &max_time, sizeof(max_time)) != 0) {
+ fprintf(stderr, "FAIL: failing OPENSSL_gmtime_adj didn't "
+ "zero out max_time\n");
+ goto err;
+ }
+ max_time = copy;
min_time.tm_year = 0 - 1900;
min_time.tm_mon = 1 - 1;
"fail for minimum time\n");
goto err;
}
+ if (memcmp(&zero, &min_time, sizeof(min_time)) != 0) {
+ fprintf(stderr, "FAIL: failing OPENSSL_gmtime_adj didn't "
+ "zero out max_time\n");
+ goto err;
+ }
+ min_time = copy;
/* Test that we can offset by the valid minimum and maximum times. */
if (!OPENSSL_gmtime_adj(©, 0, valid_time_range)) {
goto err;
}
if (memcmp(©, &max_time, sizeof(max_time)) != 0) {
- fprintf(stderr, "FAIL: maximally adjusted copy didn't match"
+ fprintf(stderr, "FAIL: maximally adjusted copy didn't match "
"max_time\n");
+ hexdump((unsigned char *)&max_time, sizeof(max_time));
+ hexdump((unsigned char *)©, sizeof(copy));
goto err;
}
if (!OPENSSL_gmtime_adj(©, 0, -valid_time_range)) {
goto err;
}
if (memcmp(©, &min_time, sizeof(min_time)) != 0) {
- fprintf(stderr, "FAIL: maximally adjusted copy didn't match"
+ fprintf(stderr, "FAIL: maximally adjusted copy didn't match "
"min_time\n");
goto err;
}