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 <agl@google.com>
chromium-5359
David Benjamin 4 years ago committed by Adam Langley
parent c6ffcde8cd
commit c509ee3fa2
  1. 8
      crypto/x509/x509_set.c
  2. 12
      crypto/x509/x509cset.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;
}
}

@ -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;
}
}

Loading…
Cancel
Save