From c509ee3fa27d191b23da353d363c396ef7bdecdb Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Tue, 10 Nov 2020 02:24:09 -0500 Subject: [PATCH] Switch M_ASN1_TIME macros within the library. There is no ASN1_TIME_dup, so switch M_ASN1_TIME_dup to ASN1_STRING_dup as upstream does. Switch M_ASN1_TIME_free to ASN1_TIME_free, also matching upstream. This is a no-op, but less obviously so: ASN1_TIME is an MSTRING defined in a_time.c. This defines an MSTRING ASN1_ITEM. The new/free functions are then generated with IMPLEMENT_ASN1_FUNCTIONS, which walks the ASN1_ITEM. ASN1_TIME_free then goes through table-based free function, eventually running ASN1_primitive_free, which calls ASN1_STRING_free on MSTRINGs. Change-Id: I1765848a5301ecceeb74f91457351c969b741bb1 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44046 Reviewed-by: Adam Langley --- crypto/x509/x509_set.c | 8 ++++---- crypto/x509/x509cset.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c index 6141af0d9..5f1785198 100644 --- a/crypto/x509/x509_set.c +++ b/crypto/x509/x509_set.c @@ -125,9 +125,9 @@ int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm) return (0); in = x->cert_info->validity->notBefore; if (in != tm) { - in = M_ASN1_TIME_dup(tm); + in = ASN1_STRING_dup(tm); if (in != NULL) { - M_ASN1_TIME_free(x->cert_info->validity->notBefore); + ASN1_TIME_free(x->cert_info->validity->notBefore); x->cert_info->validity->notBefore = in; } } @@ -168,9 +168,9 @@ int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm) return (0); in = x->cert_info->validity->notAfter; if (in != tm) { - in = M_ASN1_TIME_dup(tm); + in = ASN1_STRING_dup(tm); if (in != NULL) { - M_ASN1_TIME_free(x->cert_info->validity->notAfter); + ASN1_TIME_free(x->cert_info->validity->notAfter); x->cert_info->validity->notAfter = in; } } diff --git a/crypto/x509/x509cset.c b/crypto/x509/x509cset.c index 04f1f87eb..f207a25c6 100644 --- a/crypto/x509/x509cset.c +++ b/crypto/x509/x509cset.c @@ -87,9 +87,9 @@ int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm) return (0); in = x->crl->lastUpdate; if (in != tm) { - in = M_ASN1_TIME_dup(tm); + in = ASN1_STRING_dup(tm); if (in != NULL) { - M_ASN1_TIME_free(x->crl->lastUpdate); + ASN1_TIME_free(x->crl->lastUpdate); x->crl->lastUpdate = in; } } @@ -104,9 +104,9 @@ int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm) return (0); in = x->crl->nextUpdate; if (in != tm) { - in = M_ASN1_TIME_dup(tm); + in = ASN1_STRING_dup(tm); if (in != NULL) { - M_ASN1_TIME_free(x->crl->nextUpdate); + ASN1_TIME_free(x->crl->nextUpdate); x->crl->nextUpdate = in; } } @@ -202,9 +202,9 @@ int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm) return (0); in = x->revocationDate; if (in != tm) { - in = M_ASN1_TIME_dup(tm); + in = ASN1_STRING_dup(tm); if (in != NULL) { - M_ASN1_TIME_free(x->revocationDate); + ASN1_TIME_free(x->revocationDate); x->revocationDate = in; } }