Skip to content

Commit 33b5113

Browse files
rushilmehrakornelski
authored andcommitted
Fix bug with accessing memzero'd X509StoreContext in tests
As of https://boringssl-review.googlesource.com/c/boringssl/+/64141, X509_STORE_CTX_cleanup will zero the memory allocated to the X509_STORE_CTX. Because X509StoreContextRef::init invokes X509_STORE_CTX_cleanup once the with_context closure has finished, calling X509StoreContextRef::verify_result (or any API really) is going to be invalid because memory has been zerod out. This is a pretty big footgun, so maybe we should consider screaming a bit louder for this case.
1 parent c05a339 commit 33b5113

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

boring/src/x509/tests/trusted_first.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ fn verify(
9393

9494
let mut store_ctx = X509StoreContext::new().unwrap();
9595

96-
let _ = store_ctx.init(&trusted, cert, &untrusted, |ctx| {
97-
configure(ctx.verify_param_mut());
98-
ctx.verify_cert().unwrap();
99-
100-
Ok(())
101-
});
102-
103-
store_ctx.verify_result()
96+
store_ctx
97+
.init(&trusted, cert, &untrusted, |ctx| {
98+
configure(ctx.verify_param_mut());
99+
ctx.verify_cert().unwrap();
100+
101+
Ok(ctx.verify_result())
102+
})
103+
.expect("failed to obtain X509VerifyResult")
104104
}

0 commit comments

Comments
 (0)