diff --git a/openssl/CHANGELOG.md b/openssl/CHANGELOG.md index d734fbbce..e3d1045ac 100644 --- a/openssl/CHANGELOG.md +++ b/openssl/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +## [v0.10.66] - 2024-07-21 + +### Fixed + +- Fixed undefined behavior in `MemBio::get_buf` when the resulting buffer had a length of 0. + ## [v0.10.65] - 2024-07-20 ### Fixed @@ -902,7 +908,8 @@ Look at the [release tags] for information about older releases. -[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.65...master +[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.66...master +[v0.10.66]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.65...openssl-v0.10.66 [v0.10.65]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.64...openssl-v0.10.65 [v0.10.64]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.63...openssl-v0.10.64 [v0.10.63]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.62...openssl-v0.10.63 diff --git a/openssl/Cargo.toml b/openssl/Cargo.toml index bb9439828..cc8ef0acc 100644 --- a/openssl/Cargo.toml +++ b/openssl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openssl" -version = "0.10.65" +version = "0.10.66" authors = ["Steven Fackler "] license = "Apache-2.0" description = "OpenSSL bindings" diff --git a/openssl/src/bio.rs b/openssl/src/bio.rs index 96a63d19c..1595f89f1 100644 --- a/openssl/src/bio.rs +++ b/openssl/src/bio.rs @@ -63,7 +63,11 @@ impl MemBio { unsafe { let mut ptr = ptr::null_mut(); let len = ffi::BIO_get_mem_data(self.0, &mut ptr); - slice::from_raw_parts(ptr as *const _ as *const _, len as usize) + if len == 0 { + &[] + } else { + slice::from_raw_parts(ptr as *const _ as *const _, len as usize) + } } } @@ -83,3 +87,14 @@ cfg_if! { } } } + +#[cfg(test)] +mod tests { + use super::MemBio; + + #[test] + fn test_mem_bio_get_buf_empty() { + let b = MemBio::new().unwrap(); + assert_eq!(b.get_buf(), &[]); + } +} 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