Skip to content

Commit 7051b25

Browse files
committed
Manually error on embedded nul for set_ciphers
1 parent 4fc45d2 commit 7051b25

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

vm/src/stdlib/ssl.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,14 @@ impl PySslContext {
364364
}
365365

366366
#[pymethod]
367-
fn set_ciphers(&self, cipherlist: CString, vm: &VirtualMachine) -> PyResult<()> {
368-
self.builder()
369-
.set_cipher_list(cipherlist.to_str().unwrap())
370-
.map_err(|_| {
371-
vm.new_exception_msg(ssl_error(vm), "No cipher can be selected.".to_owned())
372-
})
367+
fn set_ciphers(&self, cipherlist: PyStringRef, vm: &VirtualMachine) -> PyResult<()> {
368+
let ciphers = cipherlist.as_str();
369+
if ciphers.contains('\0') {
370+
return Err(vm.new_value_error("embedded null character".to_owned()));
371+
}
372+
self.builder().set_cipher_list(ciphers).map_err(|_| {
373+
vm.new_exception_msg(ssl_error(vm), "No cipher can be selected.".to_owned())
374+
})
373375
}
374376

375377
#[pyproperty]

0 commit comments

Comments
 (0)