Skip to content

use rb_ary_entry in yajl_encode_part to avoid stale RARRAY_PTR#235

Open
jmestwa-coder wants to merge 1 commit into
brianmario:masterfrom
jmestwa-coder:encode-array-rarray-ptr-uaf
Open

use rb_ary_entry in yajl_encode_part to avoid stale RARRAY_PTR#235
jmestwa-coder wants to merge 1 commit into
brianmario:masterfrom
jmestwa-coder:encode-array-rarray-ptr-uaf

Conversation

@jmestwa-coder

Copy link
Copy Markdown

Noticed the T_ARRAY case in yajl_encode_part caches VALUE *ptr = RARRAY_PTR(obj) and then walks ptr[idx]. But each element can run Ruby (a member's to_s/to_json, or the on_progress block during a buffer flush); if that grows the same array its backing store is reallocated and ptr dangles, so the next ptr[idx] reads freed memory and segfaults. Reading through rb_ary_entry(obj, idx) hits the live buffer each pass and is bounds-checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant