-
-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Labels
Description
Things to check first
-
I have searched the existing issues and didn't find my bug already reported there
-
I have checked that my bug is still present in the latest release
cbor2 version
5.8.0
Python version
3.9.18
What happened?
When decoding CBOR tag 5 (bigfloat) with a null mantissa, CBORDecoder.decode() raises TypeError instead of the expected CBORDecodeValueError. This is probably because the try/except in decode_bigfloat only covers self._decode() , leaving the Decimal(sig) * (2 ** Decimal(exp)) computation outside its scope.
How can we reproduce the bug?
data = bytes.fromhex("c58200f6")
obj = cbor2.CBORDecoder(io.BytesIO(data))
print(obj.decode())
trace:
Traceback (most recent call last):
File "test.py", line 60, in <module>
print(obj.decode())
TypeError: unsupported operand type(s) for *: 'NoneType' and 'decimal.Decimal'
Expected behavior: should raise CBORDecodeValueError, consistent with other invalid input.
Reactions are currently unavailable