Revert "lzma: Make sure we don't dereference past array"
PATCH 1/1 Revert "lzma: Make sure we don't dereference past array"
Commit 40e261b89b71 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 unreachable and no longer necessary.
This reverts commit 16c0dbf4bc6a953c41bc7a031b36dfa8e906afea.
--- grub-core/lib/LzmaEnc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
grub-core/lib/LzmaEnc.c +2 -8
@@ -1877,7 +1877,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize }else { -UInt32 posSlot, lenToPosState; +UInt32 posSlot;RangeEnc_EncodeBit (&p->rc, &p->isRep[p->state],0 ); p->state = kMatchNextStates[p->state];if (len <LZMA_MATCH_LEN_MIN )
@@ -1888,13 +1888,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSizeLenEnc_Encode2 (&p->lenEnc, &p->rc, len -LZMA_MATCH_LEN_MIN , posState, !p->fastMode, p->ProbPrices); pos -=LZMA_NUM_REPS ;GetPosSlot (pos, posSlot); - lenToPosState =GetLenToPosState (len); -if (lenToPosState >= kNumLenToPosStates) - { - p->result =SZ_ERROR_DATA ; -return CheckErrors (p); - } -RcTree_Encode (&p->rc, p->posSlotEncoder[lenToPosState], kNumPosSlotBits, posSlot); +RcTree_Encode (&p->rc, p->posSlotEncoder[GetLenToPosState (len)], kNumPosSlotBits, posSlot);if (posSlot >= kStartPosModelIndex) {
Signature · 7 lines
2.43.5 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · Lidong Chen
Commit
40e261b89b71ensures 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 commit16c0dbf4bc6aunreachable and no longer necessary.This reverts commit
16c0dbf4bc6a953c41bc7a031b36dfa8e906afea.Fixes CID 481982Signed-off-by Lidong Chen <[email protected]>
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel