Skip to content

CBOR::StackError is not rescued by COSE::Key.cbor_decode #83

Description

@santiagorodriguez96

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions