You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ffi: exportArrayBuffer type check is fooled by Symbol.toStringTag #66454
importffifrom'node:ffi';constdest=newArrayBuffer(8);constptr=ffi.getRawPointer(dest);// Real ArrayBuffer with a custom tag: rejected.constreal=newArrayBuffer(4);Object.defineProperty(real,Symbol.toStringTag,{value: 'Custom'});try{ffi.exportArrayBuffer(real,ptr,8);}catch(err){console.log('real:',err.code,err.message);}// Fake object tagged as ArrayBuffer: passes the JS check.constfake={[Symbol.toStringTag]: 'ArrayBuffer',byteLength: 4};try{ffi.exportArrayBuffer(fake,ptr,8);}catch(err){console.log('fake:',err.code,err.message);}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
So the check should depend on whether the value really is an ArrayBuffer, not on its tag. A real ArrayBuffer should be copied.
The fake object should be rejected in JS with The "arrayBuffer" argument must be an instance of ArrayBuffer.
What do you see instead?
real: ERR_INVALID_ARG_TYPE The "arrayBuffer" argument must be an instance of ArrayBuffer. Received an instance of ArrayBufferfake: ERR_INVALID_ARG_TYPE The first argument must be a Buffer, ArrayBuffer, SharedArrayBuffer, or ArrayBufferView
Activity
ffi: fix exportArrayBuffer type check
ffi: fix exportArrayBuffer type check