The cbor gem caps nesting depth at 128 (MSGPACK_UNPACKER_STACK_CAPACITY) and raises CBOR::StackError. That class isn't in cbor_decode's rescue list, so it escapes as a cbor gem error instead of COSE::MalformedKeyError:
require "cose/key"
require "uri" # so the NameError in #82 doesn't mask this
deep = 0
129.times { deep = [deep] }
COSE::Key.deserialize(deep.to_cbor)
# CBOR::StackError: stack level too deep
Callers shouldn't have to rescue cbor gem classes. We should add CBOR::StackError to the list of rescued exceptions so that COSE::MalformedKeyError is raised instead.
The
cborgem caps nesting depth at 128 (MSGPACK_UNPACKER_STACK_CAPACITY) and raisesCBOR::StackError. That class isn't incbor_decode's rescue list, so it escapes as acborgem error instead ofCOSE::MalformedKeyError:Callers shouldn't have to rescue
cborgem classes. We should addCBOR::StackErrorto the list of rescued exceptions so thatCOSE::MalformedKeyErroris raised instead.