This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Passing null/undefined for options crashes node #1574
Closed
Description
It's legal to pass null
/undefined
as a value for options. In some instances our API methods expect an options object to exist and try to access properties on it, which fails and crashes the node.
e.g.
js-ipfs/src/core/components/files.js
Lines 279 to 281 in e7d1270
^^ in this instance, the default assignment only happens if options is undefined
so does not work correctly if null
is passed.
It could happen if the user is using a ternary to pass/not pass options e.g.
const hashAlg = 'sha2-512' // Obtained from user input perhaps
await ipfs.files.add(Buffer.from('data'), hashAlg ? { hashAlg } : null)`