Merge pull request #1328 from toorls/dev-v3

Fix time related bug
This commit is contained in:
Zhi Guan
2022-10-12 21:39:27 +08:00
committed by GitHub
4 changed files with 4 additions and 4 deletions

View File

@@ -1193,7 +1193,7 @@ int asn1_utc_time_from_der_ex(int tag, time_t *t, const uint8_t **pin, size_t *p
}
if (len == sizeof("YYMMDDHHMMSSZ")-1) {
#ifdef WIN32
asn1_generalizedtime_to_tm(&tm_val, buf);
asn1_generalizedtime_to_tm(buf, &tm_val);
*t = GMSSL_timegm(&tm_val);
#else
if (!strptime(buf, "%Y%m%d%H%M%SZ", &tm_val)) {

View File

@@ -143,7 +143,7 @@ int GMSSL_gmtime_adj(struct tm *tm, long offset_sec)
}
//convert generalizedtime to tm
int asn1_generalizedtime_to_tm(struct tm *tm, char *gtime)
int asn1_generalizedtime_to_tm(char *gtime,struct tm *tm)
{
static const int min[9] = { 0, 0, 1, 1, 0, 0, 0, 0, 0 };
static const int max[9] = { 99, 99, 12, 31, 23, 59, 59, 12, 59 };

View File

@@ -15,7 +15,7 @@ extern "C" {
int GMSSL_gmtime(const time_t *timep, struct tm *tm_time);
time_t GMSSL_timegm(struct tm *tm);
int GMSSL_gmtime_adj(struct tm *tm, long offset_sec);
int asn1_generalizedtime_to_tm(struct tm *tm,char *gtime);
int asn1_generalizedtime_to_tm(char *gtime,struct tm *tm);
int asn1_utctime_to_tm(struct tm *tm, char *utime);
int asn1_tm_to_generalizedtime(struct tm *tm, char *gtime);
int asn1_tm_to_utctime(struct tm *tm, char *utime);

View File

@@ -589,7 +589,7 @@ int main(void)
if (test_asn1_utf8_string() != 1) goto err;
if (test_asn1_ia5_string() != 1) goto err;
if (test_asn1_utc_time() != 1) goto err;
//if (test_asn1_generalized_time() != 1) goto err;
if (test_asn1_generalized_time() != 1) goto err;
printf("%s all tests passed\n", __FILE__);
return 0;
err: