sqlite3: reject negative fetchmany values (#7240)

This commit is contained in:
Jiseok CHOI authored and GitHub committed 2026-02-27 21:03:40 +09:00
1 parent 0d1e0d48e8
commit 3f86af32f3
2 files changed
+10 -4

No files matched your search

-1
View File
@@ -1125,7 +1125,6 @@ class CursorTests(unittest.TestCase):
res = self.cu.fetchmany(100)
self.assertEqual(res, [])
@unittest.expectedFailure # TODO: RUSTPYTHON fetchmany size validation not implemented
def test_invalid_fetchmany(self):
UINT32_MAX = (1 << 32) - 1
fetchmany = self.cu.fetchmany
+10 -3
View File
@@ -1883,9 +1883,16 @@ mod _sqlite3 {
args: FetchManyArgs,
vm: &VirtualMachine,
) -> PyResult<Vec<PyObjectRef>> {
let max_rows = args
.size
.unwrap_or_else(|| zelf.arraysize.load(Ordering::Relaxed));
let max_rows = match args.size {
Some(size) => {
if size < 0 {
return Err(vm.new_value_error("fetchmany may not be negative"));
}
size
}
None => zelf.arraysize.load(Ordering::Relaxed),
};
let mut list = vec![];
while let PyIterReturn::Return(row) = Cursor::next(zelf, vm)? {