Fix TypedArray.prototype.with TOCTOU heap over-read#1415
Conversation
Re-validate the typed array after JS_ToPrimitive (which can trigger user code that resizes or detaches the backing ArrayBuffer). Ref: bellard/quickjs#492
bnoordhuis
left a comment
There was a problem hiding this comment.
This particular class of bugs keeps popping up, doesn't it?
Wild thought: maybe we should start renaming functions that (directly or indirectly) invoke JS so it's more obvious where extra attention is needed.
For example, JS_ToPrimitive would become JS_ToPrimitiveOSE (for Observable Side Effects.) The downside is lots of churn, obviously.
It does! 😅
Not wild! Right now we do have a but of an inherited mix: Honestly I'm not very worried about churn. It was annoying when manually porting patches over, but AI is good at figuring that out. I wonder if some soem macro in the function prototype can help? |
Re-validate the typed array after JS_ToPrimitive (which can trigger
user code that resizes or detaches the backing ArrayBuffer).
Ref: bellard/quickjs#492