Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use-after-free in cms #942

Merged
merged 1 commit into from
Jun 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions openssl/src/cms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,14 @@ impl CmsContentInfo {
flags: CMSOptions,
) -> Result<CmsContentInfo, ErrorStack> {
unsafe {
let signcert = match signcert {
Some(cert) => cert.as_ptr(),
None => ptr::null_mut(),
};
let pkey = match pkey {
Some(pkey) => pkey.as_ptr(),
None => ptr::null_mut(),
};
let data_bio_ptr = match data {
Some(data) => MemBioSlice::new(data)?.as_ptr(),
None => ptr::null_mut(),
};
let certs = match certs {
Some(certs) => certs.as_ptr(),
None => ptr::null_mut(),
let signcert = signcert.map_or(ptr::null_mut(), |p| p.as_ptr());
let pkey = pkey.map_or(ptr::null_mut(), |p| p.as_ptr());
let data_bio = match data {
Some(data) => Some(MemBioSlice::new(data)?),
None => None,
};
let data_bio_ptr = data_bio.as_ref().map_or(ptr::null_mut(), |p| p.as_ptr());
let certs = certs.map_or(ptr::null_mut(), |p| p.as_ptr());

let cms = cvt_p(ffi::CMS_sign(
signcert,
Expand Down