cbor-gen
cbor-gen copied to clipboard
WriteCid should fail if the Cid in question doesn't pass checks that would cause it to fail if read in ReadCid
WriteCid
accepts CIDs with length >= 1, writing a MajByteString
with at least length 2: https://github.com/whyrusleeping/cbor-gen/blob/0b9f6c5fb1636544f94f5087817df99699de49ba/utils.go#L581-L588
The following requirements exist for ReadCid
, but do not exist for WriteCid
:
-
ReadCid
errors if read length is over 512: https://github.com/whyrusleeping/cbor-gen/blob/0b9f6c5fb1636544f94f5087817df99699de49ba/utils.go#L550 -
ReadCid
errors if first read byte is nonzero: https://github.com/whyrusleeping/cbor-gen/blob/0b9f6c5fb1636544f94f5087817df99699de49ba/utils.go#L568-L570 -
ReadCid
errors if read bytes do not pass several checks incid.Cast
: https://github.com/whyrusleeping/cbor-gen/blob/0b9f6c5fb1636544f94f5087817df99699de49ba/utils.go#L572