bound recovery scan to input end in xs_textdecoder_decode#1637
bound recovery scan to input end in xs_textdecoder_decode#1637rootvector2 wants to merge 1 commit into
Conversation
|
Interesting find. I believe the proposed change will avoid the out of bounds read. But I think there may be a bug lurking in that code path that is the real source of the problem. I need to investigate a bit further. |
|
agreed, the bounds check only stops the over-read. the root cause is that the recovery loop scans continuation bytes straight from |
|
I think I'd do something like this: It reuses |
…_decode the illegal-sequence recovery loop read continuation bytes straight from src and advanced src for each one, ignoring the bytes carried over in the streaming buffer. completing a buffered partial lead with a short final chunk walked src past the view end and passed a negative length to the trailing c_memcpy. read the already-assembled utf8 bytes and advance buffer or src the same way the legal decode path does, in both passes.
f690635 to
8e8b58c
Compare
|
makes sense, that's the real fix. reworked both loops to read the continuation bytes from |
|
Thanks for reviewing, testing, and integrating. We'll get this merged. |
|
This has been merged and will be available in the next release. |
the illegal-sequence recovery loop in
xs_textdecoder_decodescans continuation bytes without checkingsrc < srcEnd, so a streamingdecode()that finishes a buffered partial lead with a short final chunk runssrcpast the input and passes a negative length to the trailingc_memcpy; caught with an asan build of xst.