Skip to content

Commit 033ecf8

Browse files
author
Ralph Küpper
committed
review(#6014): reject GC_TYPE_LAZY_ARRAY in shape_is_url_search_params keys_array gate
CodeRabbit: a lazy array does not share the eager ArrayHeader layout, so reading (*keys_arr).length / js_array_get_f64 on one would access the wrong field. An object's own key list is always an eager GC_TYPE_ARRAY (the pre-fix code read .length directly, proving it is never lazy here), so require GC_TYPE_ARRAY specifically and reject lazy arrays — a real URLSearchParams shape never has a lazy keys_array, so returning false is correct.
1 parent 58c7204 commit 033ecf8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎crates/perry-runtime/src/url/search_params.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,14 @@ pub(crate) fn shape_is_url_search_params(obj: *const ObjectHeader) -> bool {
845845
// layout) can carry a non-heap word here; reading `(*keys_arr).length`
846846
// on it SIGSEGV'd during Next.js request handling (config.js method
847847
// dispatch probing an arbitrary receiver through this shape check).
848-
// Same try_read_gc_header gate as the receiver above.
848+
// Same try_read_gc_header gate as the receiver above. Require the
849+
// EAGER `GC_TYPE_ARRAY` layout specifically: an object's own key list
850+
// is always eager, and `(*keys_arr).length` / `js_array_get_f64` below
851+
// read the eager `ArrayHeader` fields — a `GC_TYPE_LAZY_ARRAY` doesn't
852+
// share that layout, so reject it (a real URLSearchParams shape never
853+
// has a lazy keys_array; returning false is correct).
849854
match crate::value::addr_class::try_read_gc_header(keys_arr as usize) {
850-
Some(h)
851-
if h.obj_type == crate::gc::GC_TYPE_ARRAY
852-
|| h.obj_type == crate::gc::GC_TYPE_LAZY_ARRAY => {}
855+
Some(h) if h.obj_type == crate::gc::GC_TYPE_ARRAY => {}
853856
_ => return false,
854857
}
855858
if (*keys_arr).length == 0 {

0 commit comments

Comments
 (0)