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

PEM parsing: check last error instead of first #2148

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions openssl/src/x509/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,13 @@ impl X509 {
ffi::PEM_read_bio_X509(bio.as_ptr(), ptr::null_mut(), None, ptr::null_mut());
if r.is_null() {
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
{
break;

if let Some(err) = e.errors().last() {
if err.library_code() == ffi::ERR_LIB_PEM as libc::c_int
&& err.reason_code() == ffi::PEM_R_NO_START_LINE as libc::c_int
{
break;
}
}

return Err(e);
Expand Down