Fix ssl options setter to raise ValueError for negative values and mark still-failing tests

This commit is contained in:
Jeong, YunWon committed 2026-03-01 11:37:19 +09:00
1 parent 2dcc116380
commit 91c8e6df95
2 files changed
+9 -2

No files matched your search

+8 -1
View File
@@ -1133,7 +1133,13 @@ mod _ssl {
self.ctx.read().options().bits() as _
}
#[pygetset(setter)]
fn set_options(&self, new_opts: libc::c_ulong) {
fn set_options(&self, new_opts: i64, vm: &VirtualMachine) -> PyResult<()> {
if new_opts < 0 {
return Err(vm.new_value_error(
"invalid options value".to_owned(),
));
}
let new_opts = new_opts as libc::c_ulong;
let mut ctx = self.builder();
// Get current options
let current = ctx.options().bits() as libc::c_ulong;
@@ -1153,6 +1159,7 @@ mod _ssl {
if set != 0 {
ctx.set_options(SslOptions::from_bits_truncate(set as _));
}
Ok(())
}
#[pygetset]
fn protocol(&self) -> i32 {
+1 -1
View File
@@ -959,7 +959,7 @@ mod _ssl {
fn set_options(&self, value: i32, vm: &VirtualMachine) -> PyResult<()> {
// Validate that the value is non-negative
if value < 0 {
return Err(vm.new_overflow_error("options must be non-negative".to_owned()));
return Err(vm.new_value_error("options must be non-negative".to_owned()));
}
// Deprecated SSL/TLS protocol version options