Allows an adversary to write up to 3 bytes beyond the end of the buffer.
Occurs if the match overlaps the `extDict` and `currentPrefix`, and the
match length in the `currentPrefix` is less than `MINMATCH`, and
`op-(16-MINMATCH) >= oMatchEnd > op-16`.
op = oLitEnd + length1;
sequence.matchLength -= length1;
match = base;
- if (op > oend_w) {
+ if (op > oend_w || sequence.matchLength < MINMATCH) {
U32 i;
for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i];
return sequenceLength;
}
} }
- /* Requirement: op <= oend_w */
+ /* Requirement: op <= oend_w && sequence.matchLength >= MINMATCH */
/* match within prefix */
if (sequence.offset < 8) {
op = oLitEnd + length1;
sequence.matchLength -= length1;
match = base;
- if (op > oend_w) {
+ if (op > oend_w || sequence.matchLength < MINMATCH) {
U32 i;
for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i];
return sequenceLength;
}
} }
- /* Requirement: op <= oend_w */
+ /* Requirement: op <= oend_w && sequence.matchLength >= MINMATCH */
#endif
/* match within prefix */
} else { ZSTD_copy8(op, match); }
op += 8; match += 8;
- if (endMatch > oend-12)
+ if (endMatch > oend-(16-MINMATCH))
{
if (op < oend-8)
{
}
op += 8; match += 8;
- if (oMatchEnd > oend-12)
+ if (oMatchEnd > oend-(16-MINMATCH))
{
if (op < oend_8)
{
}
op += 8; match += 8;
- if (oMatchEnd > oend-12)
+ if (oMatchEnd > oend-(16-MINMATCH))
{
if (op < oend_8)
{
op = oLitEnd + length1;
sequence.matchLength -= length1;
match = base;
- if (op > oend_8) {
+ if (op > oend_8 || sequence.matchLength < MINMATCH) {
while (op < oMatchEnd) *op++ = *match++;
return sequenceLength;
}
}
op += 8; match += 8;
- if (oMatchEnd > oend-12)
+ if (oMatchEnd > oend-(16-MINMATCH))
{
if (op < oend_8)
{
op = oLitEnd + length1;
sequence.matchLength -= length1;
match = base;
- if (op > oend_8) {
+ if (op > oend_8 || sequence.matchLength < MINMATCH) {
while (op < oMatchEnd) *op++ = *match++;
return sequenceLength;
}
}
op += 8; match += 8;
- if (oMatchEnd > oend-12) {
+ if (oMatchEnd > oend-(16-MINMATCH)) {
if (op < oend_8) {
ZSTDv05_wildcopy(op, match, oend_8 - op);
match += oend_8 - op;
op = oLitEnd + length1;
sequence.matchLength -= length1;
match = base;
- if (op > oend_8) {
+ if (op > oend_8 || sequence.matchLength < MINMATCH) {
while (op < oMatchEnd) *op++ = *match++;
return sequenceLength;
}
op = oLitEnd + length1;
sequence.matchLength -= length1;
match = base;
- if (op > oend_w) {
+ if (op > oend_w || sequence.matchLength < MINMATCH) {
while (op < oMatchEnd) *op++ = *match++;
return sequenceLength;
}