Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/iocore/cache/CacheVC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,17 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
}
break;
}
if (doc->data() - buf->data() > static_cast<int>(io.aiocb.aio_nbytes)) {
might_need_overlap_read = true;
goto Lskip;
{
size_t const doc_off = reinterpret_cast<char *>(doc) - buf->data();
// Bounds-check in unsigned domain: doc must lie within the
// buffer, with room for the Doc header, and doc->hlen must
// fit in the remaining bytes before doc->hdr() and
// HTTPInfo::unmarshal walk it.
if (io.aiocb.aio_nbytes < doc_off || (io.aiocb.aio_nbytes - doc_off) < sizeof(Doc) ||
(io.aiocb.aio_nbytes - doc_off - sizeof(Doc)) < doc->hlen) {
might_need_overlap_read = true;
goto Lskip;
}
}
{
char *tmp = doc->hdr();
Expand Down