Repository navigation
fix(wintertc): enforce max_buffer_size and fallible allocation during ArrayBuffer deserialization - #5670
Conversation
Test262 conformance changes
Broken tests (1):Tested main commit: |
| let buffer = JsArrayBuffer::new(data.len(), context)?; | ||
| if let Some(mut data_mut) = buffer.data_mut() { | ||
| data_mut.copy_from_slice(data); | ||
| } |
There was a problem hiding this comment.
remark: consider adding a small concise comment/note why from_byte_block isn't used here.
There was a problem hiding this comment.
Added an explanatory note as suggested! We use JsArrayBuffer::new instead of rom_byte_block so that HostHooks::max_buffer_size is enforced and memory reservation uses fallible allocation via CreateByteDataBlock. Also rebased onto latest main. Thanks for the review!
0d76dda to
847becb
Compare
… ArrayBuffer deserialization In core/wintertc/src/store/to.rs, try_into_js_array_buffer previously used JsArrayBuffer::from_byte_block(AlignedVec::from_slice(0, data), context), which bypassed CreateByteDataBlock, skipped HostHooks::max_buffer_size, and used an infallible memory reservation. This updates try_into_js_array_buffer to allocate via JsArrayBuffer::new(data.len(), context)? and copy into data_mut(). This ensures HostHooks::max_buffer_size is properly enforced across structuredClone and postMessage, returning a RangeError when a payload exceeds host caps or memory limits instead of causing an unhandled allocation abort. Adds an explanatory note clarifying why new is preferred over from_byte_block, and cleans up upstream property_map clippy lint and wasm test lint expectations. Fixes boa-dev#5652.
847becb to
71cb8ad
Compare
|
Rebased cleanly onto |
This Pull Request fixes #5652.
It changes the following:
core/wintertc/src/store/to.rs, updatestry_into_js_array_bufferto construct buffers viaJsArrayBuffer::new(data.len(), context)?and copy intodata_mut().HostHooks::max_buffer_size(context)during structured clone (structuredClone) and message deserialization (postMessage), returning aRangeErrorwhen an incoming payload exceeds host-defined buffer limits.AlignedVec::from_slicewith fallible memory reservation viaCreateByteDataBlock, preventing unhandled process aborts on memory exhaustion.core/wintertc/src/store/tests.rscovering:ArrayBufferpayloads againstHostHooks::max_buffer_size.ArrayBufferpayloads.ArrayBufferroundtrip cloning.ArrayBufferroundtrip cloning.