Skip to content

Commit f03a2dc

Browse files
authored
Merge pull request #1968 from sfackler/empty-domain-segfault
Fix handling of empty host strings
2 parents 8e16a8b + 155b3dc commit f03a2dc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

openssl/src/x509/verify.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ impl X509VerifyParamRef {
120120
#[corresponds(X509_VERIFY_PARAM_set1_host)]
121121
pub fn set_host(&mut self, host: &str) -> Result<(), ErrorStack> {
122122
unsafe {
123+
// len == 0 means "run strlen" :(
124+
let raw_host = if host.is_empty() { "\0" } else { host };
123125
cvt(ffi::X509_VERIFY_PARAM_set1_host(
124126
self.as_ptr(),
125-
host.as_ptr() as *const _,
127+
raw_host.as_ptr() as *const _,
126128
host.len(),
127129
))
128130
.map(|_| ())

0 commit comments

Comments
 (0)