diff options
| author | Jeff Epler <jepler@gmail.com> | 2025-08-06 10:15:57 -0500 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-08-15 01:21:25 +1000 |
| commit | 0615d13963ba33650a5b2070368584c7aec9c9dd (patch) | |
| tree | cffa9af1a737e552ee5a3f342a3c977890f05a72 /tests/micropython/ringio_big.py | |
| parent | 803da9645f735edd3d1a80a3f920039e0f0298f2 (diff) | |
py/objringio: Detect incorrect constructor calls.
ringbuffer.size must be at least 2, and is a 16-bit quantity.
This fixes several cases including the one the fuzzer discovered, which
would lead to a fatal signal when accessing the object.
Fixes issue #17847.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'tests/micropython/ringio_big.py')
| -rw-r--r-- | tests/micropython/ringio_big.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/micropython/ringio_big.py b/tests/micropython/ringio_big.py new file mode 100644 index 000000000..d55c4c00b --- /dev/null +++ b/tests/micropython/ringio_big.py @@ -0,0 +1,29 @@ +# Check that micropython.RingIO works correctly. + +import micropython + +try: + micropython.RingIO +except AttributeError: + print("SKIP") + raise SystemExit + +try: + # The maximum possible size + micropython.RingIO(bytearray(65535)) + micropython.RingIO(65534) + + try: + # Buffer may not be too big + micropython.RingIO(bytearray(65536)) + except ValueError as ex: + print(type(ex)) + + try: + # Size may not be too big + micropython.RingIO(65535) + except ValueError as ex: + print(type(ex)) +except MemoryError: + print("SKIP") + raise SystemExit |
