Fix bounds check in ZSTD_storeSeq()

This commit is contained in:
Nick Terrell 2019-09-20 08:25:12 -07:00
parent 67b1f5fc72
commit fde217df04

View File

@ -361,8 +361,8 @@ MEM_STATIC void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const B
assert(seqStorePtr->maxNbLit <= 128 KB);
assert(seqStorePtr->lit + litLength <= seqStorePtr->litStart + seqStorePtr->maxNbLit);
/* We are guaranteed at least 8 bytes of literals space because of HASH_READ_SIZE. */
assert(litLimit - literals >= HASH_READ_SIZE);
if (litLimit - literals >= WILDCOPY_OVERLENGTH)
assert(literals + litLength + HASH_READ_SIZE <= litLimit);
if (literals + litLength + WILDCOPY_OVERLENGTH <= litLimit)
ZSTD_wildcopy(seqStorePtr->lit, literals, (ptrdiff_t)litLength, ZSTD_no_overlap);
else
ZSTD_wildcopy8(seqStorePtr->lit, literals, (ptrdiff_t)litLength);