Use scopers a little more.
Change-Id: I51e5a7dac3ceffc41d3a7a57157a11258e65bc42 Reviewed-on: https://boringssl-review.googlesource.com/11721 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
be941d4659
commit
a7f56f0bfb
@ -1024,14 +1024,12 @@ static bool TestASN1() {
|
||||
}
|
||||
|
||||
// Test the value serializes correctly.
|
||||
CBB cbb;
|
||||
bssl::ScopedCBB cbb;
|
||||
uint8_t *der;
|
||||
size_t der_len;
|
||||
CBB_zero(&cbb);
|
||||
if (!CBB_init(&cbb, 0) ||
|
||||
!BN_marshal_asn1(&cbb, bn.get()) ||
|
||||
!CBB_finish(&cbb, &der, &der_len)) {
|
||||
CBB_cleanup(&cbb);
|
||||
if (!CBB_init(cbb.get(), 0) ||
|
||||
!BN_marshal_asn1(cbb.get(), bn.get()) ||
|
||||
!CBB_finish(cbb.get(), &der, &der_len)) {
|
||||
return false;
|
||||
}
|
||||
bssl::UniquePtr<uint8_t> delete_der(der);
|
||||
@ -1114,16 +1112,13 @@ static bool TestASN1() {
|
||||
if (!bn) {
|
||||
return false;
|
||||
}
|
||||
CBB cbb;
|
||||
CBB_zero(&cbb);
|
||||
if (!CBB_init(&cbb, 0) ||
|
||||
BN_marshal_asn1(&cbb, bn.get())) {
|
||||
bssl::ScopedCBB cbb;
|
||||
if (!CBB_init(cbb.get(), 0) ||
|
||||
BN_marshal_asn1(cbb.get(), bn.get())) {
|
||||
fprintf(stderr, "Serialized negative number.\n");
|
||||
CBB_cleanup(&cbb);
|
||||
return false;
|
||||
}
|
||||
ERR_clear_error();
|
||||
CBB_cleanup(&cbb);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -382,9 +382,10 @@ static bssl::UniquePtr<EVP_PKEY> PrivateKeyFromPEM(const char *pem) {
|
||||
PEM_read_bio_PrivateKey(bio.get(), nullptr, nullptr, nullptr));
|
||||
}
|
||||
|
||||
// CertsToStack converts a vector of |X509*| to an OpenSSL STACK_OF(X509*),
|
||||
// CertsToStack converts a vector of |X509*| to an OpenSSL STACK_OF(X509),
|
||||
// bumping the reference counts for each certificate in question.
|
||||
static STACK_OF(X509)* CertsToStack(const std::vector<X509*> &certs) {
|
||||
static bssl::UniquePtr<STACK_OF(X509)> CertsToStack(
|
||||
const std::vector<X509 *> &certs) {
|
||||
bssl::UniquePtr<STACK_OF(X509)> stack(sk_X509_new_null());
|
||||
if (!stack) {
|
||||
return nullptr;
|
||||
@ -396,12 +397,13 @@ static STACK_OF(X509)* CertsToStack(const std::vector<X509*> &certs) {
|
||||
X509_up_ref(cert);
|
||||
}
|
||||
|
||||
return stack.release();
|
||||
return stack;
|
||||
}
|
||||
|
||||
// CRLsToStack converts a vector of |X509_CRL*| to an OpenSSL STACK_OF(X509_CRL*),
|
||||
// bumping the reference counts for each CRL in question.
|
||||
static STACK_OF(X509_CRL)* CRLsToStack(const std::vector<X509_CRL*> &crls) {
|
||||
// CRLsToStack converts a vector of |X509_CRL*| to an OpenSSL
|
||||
// STACK_OF(X509_CRL), bumping the reference counts for each CRL in question.
|
||||
static bssl::UniquePtr<STACK_OF(X509_CRL)> CRLsToStack(
|
||||
const std::vector<X509_CRL *> &crls) {
|
||||
bssl::UniquePtr<STACK_OF(X509_CRL)> stack(sk_X509_CRL_new_null());
|
||||
if (!stack) {
|
||||
return nullptr;
|
||||
@ -413,7 +415,7 @@ static STACK_OF(X509_CRL)* CRLsToStack(const std::vector<X509_CRL*> &crls) {
|
||||
X509_CRL_up_ref(crl);
|
||||
}
|
||||
|
||||
return stack.release();
|
||||
return stack;
|
||||
}
|
||||
|
||||
static int Verify(X509 *leaf, const std::vector<X509 *> &roots,
|
||||
|
Loading…
Reference in New Issue
Block a user