diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-02-02 23:54:13 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-02-02 23:54:13 +0000 |
commit | 4fbda241ee57793390d5b0d26895f5ab4bc64c42 (patch) | |
tree | 5cbdc7aded2ed5d90e7c962b899f9acd672fc157 | |
parent | e3ec069c7637b848b8be346f22ac2532c865019c (diff) | |
parent | f261b8bfbdb3c94065c20ab66e9e76b6b81b15e4 (diff) | |
download | openssl-simpleperf-release.tar.gz |
Snap for 11400057 from f261b8bfbdb3c94065c20ab66e9e76b6b81b15e4 to simpleperf-releasesimpleperf-release
Change-Id: Icf587a42d779a5b94aadaf39037987b1544b1f31
-rw-r--r-- | .cargo/config.toml | 2 | ||||
-rw-r--r-- | Android.bp | 6 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | cargo_embargo.json | 2 | ||||
-rw-r--r-- | patches/0001-cfgs.diff | 4 | ||||
-rw-r--r-- | patches/0009-type-safety-fix.diff | 26 | ||||
-rw-r--r-- | patches/0010-type-safety-fix.diff | 67 | ||||
-rw-r--r-- | patches/Android.bp.diff | 2 | ||||
-rw-r--r-- | src/lib.rs | 11 | ||||
-rw-r--r-- | src/x509/mod.rs | 2 | ||||
-rw-r--r-- | src/x509/store.rs | 5 |
11 files changed, 115 insertions, 14 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml index 278afcd..77327b7 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ [patch.crates-io] -bssl-ffi = { package = "bssl-sys", version = "0.1.0", path = "../../../boringssl/src/rust/bssl-sys", optional=true } +bssl-sys = { version = "0.1.0", path = "../../../boringssl/src/rust/bssl-sys", optional=true } @@ -10,7 +10,7 @@ // // Even if upstreamed, cargo2android.py will likely never run correctly on // this package without modification because boringssl does not intend to -// publish "bssl-ffi" on crates.io, since it needs to match the exact local +// publish "bssl-sys" on crates.io, since it needs to match the exact local // version of boringssl. package { @@ -60,7 +60,7 @@ rust_library { ], rustlibs: [ "libbitflags-1.3.2", - "libbssl_ffi", + "libbssl_sys", "libcfg_if", "libforeign_types", "liblibc", @@ -95,7 +95,7 @@ rust_library_host_rlib { "libonce_cell", ], rlibs: [ - "libbssl_ffi_static", + "libbssl_sys_static", ], proc_macros: ["libopenssl_macros"], } @@ -60,8 +60,6 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bssl-sys" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312d12393c060384f2e6ed14c7b4be37b3dd90249857485613c1a91b9a1abb5c" [[package]] name = "cc" diff --git a/cargo_embargo.json b/cargo_embargo.json index 16df1d0..d09e89f 100644 --- a/cargo_embargo.json +++ b/cargo_embargo.json @@ -17,7 +17,7 @@ { "module_name_overrides": { "libbitflags": "libbitflags-1.3.2", - "libopenssl_sys": "libbssl_ffi" + "libopenssl_sys": "libbssl_sys" } }, { diff --git a/patches/0001-cfgs.diff b/patches/0001-cfgs.diff index ae6ba11..6cc5f29 100644 --- a/patches/0001-cfgs.diff +++ b/patches/0001-cfgs.diff @@ -5,7 +5,7 @@ index 0000000..e2b197d +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[patch.crates-io] -+bssl-ffi = { package = "bssl-sys", version = "0.1.0", path = "../../../boringssl/src/rust/bssl-sys", optional=true } ++bssl-sys = { version = "0.1.0", path = "../../../boringssl/src/rust/bssl-sys", optional=true } diff --git a/src/cipher.rs b/src/cipher.rs index ab5f49d..84a8265 100644 --- a/src/cipher.rs @@ -71,7 +71,7 @@ index 891651e..f149bfd 100644 #![warn(rust_2018_idioms)] +#[cfg(all(soong, boringssl))] -+extern crate bssl_ffi as ffi; ++extern crate bssl_sys as ffi; + #[doc(inline)] pub use ffi::init; diff --git a/patches/0009-type-safety-fix.diff b/patches/0009-type-safety-fix.diff new file mode 100644 index 0000000..a21da62 --- /dev/null +++ b/patches/0009-type-safety-fix.diff @@ -0,0 +1,26 @@ +diff --git a/src/x509/store.rs b/src/x509/store.rs +index a685fa1..418a8f2 100644 +--- a/src/x509/store.rs ++++ b/src/x509/store.rs +@@ -156,7 +156,9 @@ impl X509Lookup<HashDir> { + /// directory. + #[corresponds(X509_LOOKUP_hash_dir)] + pub fn hash_dir() -> &'static X509LookupMethodRef<HashDir> { +- unsafe { X509LookupMethodRef::from_ptr(ffi::X509_LOOKUP_hash_dir()) } ++ // `*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 _) } + } + } + +@@ -188,7 +190,9 @@ 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> { +- unsafe { X509LookupMethodRef::from_ptr(ffi::X509_LOOKUP_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 _) } + } + } + diff --git a/patches/0010-type-safety-fix.diff b/patches/0010-type-safety-fix.diff new file mode 100644 index 0000000..a3173b4 --- /dev/null +++ b/patches/0010-type-safety-fix.diff @@ -0,0 +1,67 @@ +diff --git a/src/lib.rs b/src/lib.rs +index e8d07d8..cfc6efc 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -210,6 +210,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 { +diff --git a/src/x509/mod.rs b/src/x509/mod.rs +index a03a8aa..40e5022 100644 +--- a/src/x509/mod.rs ++++ b/src/x509/mod.rs +@@ -35,7 +35,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))] +diff --git a/src/x509/store.rs b/src/x509/store.rs +index 418a8f2..2219cfc 100644 +--- a/src/x509/store.rs ++++ b/src/x509/store.rs +@@ -49,6 +49,7 @@ use crate::error::ErrorStack; + #[cfg(not(boringssl))] + use crate::ssl::SslFiletype; + use crate::stack::StackRef; ++use crate::util::ForeignTypeRefExt; + #[cfg(any(ossl102, libressl261))] + use crate::x509::verify::{X509VerifyFlags, X509VerifyParamRef}; + use crate::x509::{X509Object, X509}; +@@ -156,9 +157,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()) } + } + } + +@@ -190,9 +189,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()) } + } + } + diff --git a/patches/Android.bp.diff b/patches/Android.bp.diff index b9f0654..808329d 100644 --- a/patches/Android.bp.diff +++ b/patches/Android.bp.diff @@ -9,7 +9,7 @@ index 1e027e2..c650f2e 100644 - "libopenssl_sys", + ], + rlibs: [ -+ "libbssl_ffi_static", ++ "libbssl_sys_static", ], proc_macros: ["libopenssl_macros"], } @@ -121,7 +121,7 @@ #![warn(rust_2018_idioms)] #[cfg(all(soong, boringssl))] -extern crate bssl_ffi as ffi; +extern crate bssl_sys as ffi; #[doc(inline)] pub use ffi::init; @@ -211,6 +211,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 { Err(ErrorStack::get()) diff --git a/src/x509/mod.rs b/src/x509/mod.rs index a03a8aa..40e5022 100644 --- a/src/x509/mod.rs +++ b/src/x509/mod.rs @@ -35,7 +35,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))] diff --git a/src/x509/store.rs b/src/x509/store.rs index a685fa1..2219cfc 100644 --- a/src/x509/store.rs +++ b/src/x509/store.rs @@ -49,6 +49,7 @@ use crate::error::ErrorStack; #[cfg(not(boringssl))] use crate::ssl::SslFiletype; use crate::stack::StackRef; +use crate::util::ForeignTypeRefExt; #[cfg(any(ossl102, libressl261))] use crate::x509::verify::{X509VerifyFlags, X509VerifyParamRef}; use crate::x509::{X509Object, X509}; @@ -156,7 +157,7 @@ impl X509Lookup<HashDir> { /// directory. #[corresponds(X509_LOOKUP_hash_dir)] pub fn hash_dir() -> &'static X509LookupMethodRef<HashDir> { - unsafe { X509LookupMethodRef::from_ptr(ffi::X509_LOOKUP_hash_dir()) } + unsafe { X509LookupMethodRef::from_const_ptr(ffi::X509_LOOKUP_hash_dir()) } } } @@ -188,7 +189,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> { - unsafe { X509LookupMethodRef::from_ptr(ffi::X509_LOOKUP_file()) } + unsafe { X509LookupMethodRef::from_const_ptr(ffi::X509_LOOKUP_file()) } } } |