mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
sqlite3: reject negative fetchmany values (#7240)
This commit is contained in:
1 parent
0d1e0d48e8
commit
3f86af32f3
2 files changed
+10
-4
No files matched your search
Vendored
-1
@@ -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
|
||||
|
||||
@@ -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)? {
|
||||
|
||||
Reference in new issue
Block a user