SABITHSAHEB commented on PR #14078: URL: https://github.com/apache/trafficserver/pull/14078#issuecomment-6972500126
@JosiahWI `len` reaches the matchers but they don't actually use it as a search bound: - `strmatch::find` calls `strstr`/`strcasestr(buf, str)`, which scan to the terminator. `len` only gets checked after a hit (`found + slen > len`), so by then the read past the block has already happened. - `rxmatch::find` has `len` marked `ATS_UNUSED` and calls `regexec(&rx, buf, ...)`, which also runs to the NUL. - The carry-over `contdata->contbuf = buf + bytes_read` builds a `std::string` from a C string, so it `strlen`s past the block too. On the first block that's raw IOBuffer memory. If the block is reused, the leftover bytes from an earlier transaction get copied into `contbuf` and flushed to the client at end of stream. ASan flags the first two as heap-buffer-overflow in `strstr` and `regexec` when the block is exactly `nbytes` long. So the downstream "bug" is that `find` assumes a terminated buffer. Passing a length to `regexec` would need `REG_STARTEND`, which isn't portable, so I kept the terminated `contbuf` and added a comment on `match_t::find` stating that `buf` must be NUL-terminated at `buf[len]`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
