Skip to content

Commit 3b38923

Browse files
committed
fixes #2119 -- use ErrorStack abstraction in X.509 error handling
1 parent c428588 commit 3b38923

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

openssl/src/x509/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,6 @@ foreign_type_and_impl_send_sync! {
383383
pub struct X509Ref;
384384
}
385385

386-
#[cfg(boringssl)]
387-
type X509LenTy = c_uint;
388-
#[cfg(not(boringssl))]
389-
type X509LenTy = c_int;
390-
391386
impl X509Ref {
392387
/// Returns this certificate's subject name.
393388
#[corresponds(X509_get_subject_name)]
@@ -760,15 +755,16 @@ impl X509 {
760755
let r =
761756
ffi::PEM_read_bio_X509(bio.as_ptr(), ptr::null_mut(), None, ptr::null_mut());
762757
if r.is_null() {
763-
let err = ffi::ERR_peek_last_error();
764-
if ffi::ERR_GET_LIB(err) as X509LenTy == ffi::ERR_LIB_PEM
765-
&& ffi::ERR_GET_REASON(err) == ffi::PEM_R_NO_START_LINE
758+
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
766763
{
767-
ffi::ERR_clear_error();
768764
break;
769765
}
770766

771-
return Err(ErrorStack::get());
767+
return Err(e);
772768
} else {
773769
certs.push(X509(r));
774770
}

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