commit e536ec708f0d39b27024c80d40e420c29906a39a parent b6ec4ed7517833f60f6515fe3b708e250c33d175 Author: zhangxinlong633 <15205157627@163.com> Date: Tue, 11 Aug 2020 11:17:16 +0800 fix buffer overflow fix buffer overflow Diffstat:
| M | lib/em_inflate.c | | | 7 | ++++++- |
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/em_inflate.c b/lib/em_inflate.c @@ -598,7 +598,12 @@ static size_t em_inflate_decompress_block(em_lsb_bitreader_t *pBitReader, int nD for (i = 0; i < NLITERALSYMS; i++) { unsigned int n = nLiteralsRevSymbolTable[i]; if (n >= NMATCHLENSYMSTART && n < NLITERALSYMS) { - nLiteralsRevSymbolTable[i] = em_inflate_matchlen_code[n - NMATCHLENSYMSTART]; + int index = n - NMATCHLENSYMSTART; + if (index >= 0 && index < NMATCHLENSYMS) { + nLiteralsRevSymbolTable[i] = em_inflate_matchlen_code[index]; + } else { + return -1; + } } }