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

fixes #2119 -- use ErrorStack abstraction in X.509 error handling #2120

Merged
merged 1 commit into from
Dec 6, 2023
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
16 changes: 6 additions & 10 deletions openssl/src/x509/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,6 @@ foreign_type_and_impl_send_sync! {
pub struct X509Ref;
}

#[cfg(boringssl)]
type X509LenTy = c_uint;
#[cfg(not(boringssl))]
type X509LenTy = c_int;

impl X509Ref {
/// Returns this certificate's subject name.
#[corresponds(X509_get_subject_name)]
Expand Down Expand Up @@ -760,15 +755,16 @@ impl X509 {
let r =
ffi::PEM_read_bio_X509(bio.as_ptr(), ptr::null_mut(), None, ptr::null_mut());
if r.is_null() {
let err = ffi::ERR_peek_last_error();
if ffi::ERR_GET_LIB(err) as X509LenTy == ffi::ERR_LIB_PEM
&& ffi::ERR_GET_REASON(err) == ffi::PEM_R_NO_START_LINE
let e = ErrorStack::get();
let errors = e.errors();
if !errors.is_empty()
&& errors[0].library_code() == ffi::ERR_LIB_PEM as libc::c_int
&& errors[0].reason_code() == ffi::PEM_R_NO_START_LINE as libc::c_int
{
ffi::ERR_clear_error();
break;
}

return Err(ErrorStack::get());
return Err(e);
} else {
certs.push(X509(r));
}
Expand Down