fxamacker / cbor

CBOR codec (RFC 8949) with CBOR tags, Go struct tags (toarray, keyasint, omitempty), float64/32/16, big.Int, and fuzz tested billions of execs.
MIT License
748 stars 61 forks source link

Fix cbor.SimpleValue encoding and decoding #464

Closed fxamacker closed 11 months ago

fxamacker commented 11 months ago

Closes #462 #463

  1. Encoding cbor.SimpleValue with values 24..31 should fail because CBOR simple values 24..31 are reserved and they MUST NOT be encoded according to RFC 8949.

    This PR makes encoder return UnsupportedValueError when encoding cbor.SimpleValue with values 24..31 because that would not be a well-formed CBOR data item.

  2. Decoding other CBOR types to cbor.SimpleValue should fail because cbor.SimpleValue represents CBOR simple value (major type 7) which is different from CBOR integers and shouldn't be used interchangeably.

    This PR makes decoder return UnmarshalTypeError when decoding other CBOR types to cbor.SimpleValue.