]> git.ipfire.org Git - thirdparty/grub.git/commit
lib/LzmaEnc: Validate "len" before subtracting
authorLidong Chen <lidong.chen@oracle.com>
Thu, 12 Jun 2025 00:03:58 +0000 (00:03 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 17 Jun 2025 11:37:31 +0000 (13:37 +0200)
commit40e261b89b71cb10d8af3d1f5c9ef528592dc657
tree6abdb8282531e1de4b36ab5741ec7ae12b80d7f3
parent86e8f2c4b021c854d14d32e1bce1576dcab7c14c
lib/LzmaEnc: Validate "len" before subtracting

In LzmaEnc_CodeOneBlock(), both GetOptimumFast() and GetOptimum()
returns a value of greater or equal to 1, which is assigned to
"len". But since LZMA_MATCH_LEN_MIN == 2, "len" should be validated
before performing "len - LZMA_MATCH_LEN_MIN" to avoid underflow
when "len" equals to 1.

Fixes: CID 51508
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
grub-core/lib/LzmaEnc.c