Skip to content

Commit

Permalink
Fix handling of empty host strings
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Jun 19, 2023
1 parent 8e16a8b commit 155b3dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion openssl/src/x509/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ impl X509VerifyParamRef {
#[corresponds(X509_VERIFY_PARAM_set1_host)]
pub fn set_host(&mut self, host: &str) -> Result<(), ErrorStack> {
unsafe {
// len == 0 means "run strlen" :(
let raw_host = if host.is_empty() { "\0" } else { host };
cvt(ffi::X509_VERIFY_PARAM_set1_host(
self.as_ptr(),
host.as_ptr() as *const _,
raw_host.as_ptr() as *const _,
host.len(),
))
.map(|_| ())
Expand Down

0 comments on commit 155b3dc

Please sign in to comment.