hildjj / node-cbor

Encode and decode CBOR documents, with both easy mode, streaming mode, and SAX-style evented mode.
MIT License
356 stars 73 forks source link

diagnose crashes when cose sign1 payload is null #187

Closed OR13 closed 7 months ago

OR13 commented 7 months ago
const cbor = require('cbor-web');
(async () => {
  console.log(await cbor.diagnose(Buffer.from('d28443a10126a0f75840430c3d8593664fcc91be9e636d188161224da282b47aec290590c208ec0f350098e658614270271c04b2292e13342eaa3f8449176b0da59ecfb941f84a616282', 'hex')))
  console.log(await cbor.diagnose(Buffer.from('d28443a10126a0f65840e60e1afde353695c0aa6375e59f9f00cf48fdafe80bfd684d0b4fd001ed47078ead504c8d024baa85e4a659514868f7f74928fd5046bc78e9e8fdb202893ac4c', 'hex')))
})()

Expect payload to be primitive(22) for null and primitive(23) for undefined.

Both decode successfully on cbor.me

hildjj commented 7 months ago

Reproduced with the input '81f6'

hildjj commented 7 months ago

Fixed in 9.0.2