Skip to content

Commit aa26e97

Browse files
committed
PEM parsing: check last error instead of first
Regression introduced in #2120. Ideally, tests would not leave other errors behind. Fixes #2146
1 parent 772b0b1 commit aa26e97

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

openssl/src/x509/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -756,12 +756,13 @@ impl X509 {
756756
ffi::PEM_read_bio_X509(bio.as_ptr(), ptr::null_mut(), None, ptr::null_mut());
757757
if r.is_null() {
758758
let e = ErrorStack::get();
759-
let errors = e.errors();
760-
if !errors.is_empty()
761-
&& errors[0].library_code() == ffi::ERR_LIB_PEM as libc::c_int
762-
&& errors[0].reason_code() == ffi::PEM_R_NO_START_LINE as libc::c_int
763-
{
764-
break;
759+
760+
if let Some(err) = e.errors().last() {
761+
if err.library_code() == ffi::ERR_LIB_PEM as libc::c_int
762+
&& err.reason_code() == ffi::PEM_R_NO_START_LINE as libc::c_int
763+
{
764+
break;
765+
}
765766
}
766767

767768
return Err(e);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy