Revert "lzma: Make sure we don't dereference past array"
Commit 40e261b89b71 (lib/LzmaEnc: Validate "len" before subtracting) ensures that the variable len is at least 2. As a result, GetLenToPosState(len) never returns a value greater than or equal to kNumLenToPosStates, making the changes introduced in the commit 16c0dbf4bc6a (lzma: Make sure we don't dereference past array) unreachable and no longer necessary. This reverts commit 16c0dbf4bc6a (lzma: Make sure we don't dereference past array). Fixes: CID 481982 Signed-off-by: Lidong Chen <lidong.chen@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
2539ede82a
commit
2f2ed28d5a
@ -1877,7 +1877,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UInt32 posSlot, lenToPosState;
|
UInt32 posSlot;
|
||||||
RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
|
RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
|
||||||
p->state = kMatchNextStates[p->state];
|
p->state = kMatchNextStates[p->state];
|
||||||
if (len < LZMA_MATCH_LEN_MIN)
|
if (len < LZMA_MATCH_LEN_MIN)
|
||||||
@ -1888,13 +1888,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
|
|||||||
LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
|
LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
|
||||||
pos -= LZMA_NUM_REPS;
|
pos -= LZMA_NUM_REPS;
|
||||||
GetPosSlot(pos, posSlot);
|
GetPosSlot(pos, posSlot);
|
||||||
lenToPosState = GetLenToPosState(len);
|
RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot);
|
||||||
if (lenToPosState >= kNumLenToPosStates)
|
|
||||||
{
|
|
||||||
p->result = SZ_ERROR_DATA;
|
|
||||||
return CheckErrors(p);
|
|
||||||
}
|
|
||||||
RcTree_Encode(&p->rc, p->posSlotEncoder[lenToPosState], kNumPosSlotBits, posSlot);
|
|
||||||
|
|
||||||
if (posSlot >= kStartPosModelIndex)
|
if (posSlot >= kStartPosModelIndex)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user