Skip to content

Commit

Permalink
Merge pull request #1968 from sfackler/empty-domain-segfault
Browse files Browse the repository at this point in the history
Fix handling of empty host strings
  • Loading branch information
sfackler committed Jun 19, 2023
2 parents 8e16a8b + 155b3dc commit f03a2dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion openssl/src/x509/verify.rs
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 f03a2dc

Please sign in to comment.