From bf3764c2b225b5942bea7e96de3d429e1a4cb093 Mon Sep 17 00:00:00 2001 From: Phil Porada Date: Sun, 9 Jun 2024 13:21:44 -0400 Subject: [PATCH] Cleanup some unnecessary allocations (#849) Co-authored-by: Christopher Henderson --- .../lint_crl_revoked_certificates_field_empty.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/v3/lints/rfc/lint_crl_revoked_certificates_field_empty.go b/v3/lints/rfc/lint_crl_revoked_certificates_field_empty.go index 3fe809bb4..4ab576d37 100644 --- a/v3/lints/rfc/lint_crl_revoked_certificates_field_empty.go +++ b/v3/lints/rfc/lint_crl_revoked_certificates_field_empty.go @@ -64,23 +64,14 @@ func (l *revokedCertificates) Execute(c *x509.RevocationList) *lint.LintResult { // or confirmed to be missing from the ASN.1 data structure. input := cryptobyte.String(c.Raw) - // From crypto/x509/parser.go: we read the SEQUENCE including length and tag - // bytes so that we can populate RevocationList.Raw, before unwrapping the - // SEQUENCE so it can be operated on - if !input.ReadASN1Element(&input, cryptobyte_asn1.SEQUENCE) { - return &lint.LintResult{Status: lint.Fatal, Details: "malformed CRL"} - } + // Extract the CertificateList if !input.ReadASN1(&input, cryptobyte_asn1.SEQUENCE) { return &lint.LintResult{Status: lint.Fatal, Details: "malformed CRL"} } var tbs cryptobyte.String - // From crypto/x509/parser.go: do the same trick again as above to extract - // the raw bytes for Certificate.RawTBSCertificate - if !input.ReadASN1Element(&tbs, cryptobyte_asn1.SEQUENCE) { - return &lint.LintResult{Status: lint.Fatal, Details: "malformed TBS CRL"} - } - if !tbs.ReadASN1(&tbs, cryptobyte_asn1.SEQUENCE) { + // Extract the TBSCertList from the CertificateList + if !input.ReadASN1(&tbs, cryptobyte_asn1.SEQUENCE) { return &lint.LintResult{Status: lint.Fatal, Details: "malformed TBS CRL"} }