Skip to content

Commit 155b3dc

Browse files
committed
Fix handling of empty host strings
1 parent 8e16a8b commit 155b3dc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

openssl/src/x509/verify.rs

Lines changed: 3 additions & 1 deletion
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)