Commit 6fb228be authored by Alex Gaynor's avatar Alex Gaynor
Browse files

Fix building with latest BoringSSL

parent a3d34494
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ jobs:
            - false
          library:
            - name: boringssl
              version: f78fe19fc98e0e6f760e05c6b9d48725004700d0
              version: e6489902b7fb692875341b8ab5e57f0515f47bc1
            - name: openssl
              version: vendored
            - name: openssl
+9 −0
Original line number Diff line number Diff line
@@ -208,6 +208,15 @@ fn cvt_p<T>(r: *mut T) -> Result<*mut T, ErrorStack> {
    }
}

#[inline]
fn cvt_p_const<T>(r: *const T) -> Result<*const T, ErrorStack> {
    if r.is_null() {
        Err(ErrorStack::get())
    } else {
        Ok(r)
    }
}

#[inline]
fn cvt(r: c_int) -> Result<c_int, ErrorStack> {
    if r <= 0 {
+3 −3
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ use crate::ssl::SslRef;
use crate::stack::{Stack, StackRef, Stackable};
use crate::string::OpensslString;
use crate::util::{ForeignTypeExt, ForeignTypeRefExt};
use crate::{cvt, cvt_n, cvt_p};
use crate::{cvt, cvt_n, cvt_p, cvt_p_const};
use openssl_macros::corresponds;

#[cfg(any(ossl102, libressl261))]
@@ -2548,8 +2548,8 @@ impl X509PurposeRef {
    #[corresponds(X509_PURPOSE_get0)]
    pub fn from_idx(idx: c_int) -> Result<&'static X509PurposeRef, ErrorStack> {
        unsafe {
            let ptr = cvt_p(ffi::X509_PURPOSE_get0(idx))?;
            Ok(X509PurposeRef::from_ptr(ptr))
            let ptr = cvt_p_const(ffi::X509_PURPOSE_get0(idx))?;
            Ok(X509PurposeRef::from_const_ptr(ptr))
        }
    }

+3 −6
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ use crate::ssl::SslFiletype;
#[cfg(ossl300)]
use crate::stack::Stack;
use crate::stack::StackRef;
use crate::util::ForeignTypeRefExt;
#[cfg(any(ossl102, libressl261))]
use crate::x509::verify::{X509VerifyFlags, X509VerifyParamRef};
use crate::x509::{X509Object, X509PurposeId, X509};
@@ -165,9 +166,7 @@ impl X509Lookup<HashDir> {
    /// directory.
    #[corresponds(X509_LOOKUP_hash_dir)]
    pub fn hash_dir() -> &'static X509LookupMethodRef<HashDir> {
        // `*mut` cast is needed because BoringSSL returns a `*const`. This is
        // ok because we only return an immutable reference.
        unsafe { X509LookupMethodRef::from_ptr(ffi::X509_LOOKUP_hash_dir() as *mut _) }
        unsafe { X509LookupMethodRef::from_const_ptr(ffi::X509_LOOKUP_hash_dir()) }
    }
}

@@ -199,9 +198,7 @@ impl X509Lookup<File> {
    /// into memory at the time the file is added as a lookup source.
    #[corresponds(X509_LOOKUP_file)]
    pub fn file() -> &'static X509LookupMethodRef<File> {
        // `*mut` cast is needed because BoringSSL returns a `*const`. This is
        // ok because we only return an immutable reference.
        unsafe { X509LookupMethodRef::from_ptr(ffi::X509_LOOKUP_file() as *mut _) }
        unsafe { X509LookupMethodRef::from_const_ptr(ffi::X509_LOOKUP_file()) }
    }
}