em_inflate.c

Fast, small, in-memory inflate (zlib, deflate and gzip decompression)
git clone git://git.finwo.net/lib/em_inflate.c
Log | Files | Refs | README | LICENSE

commit ce5cefef40ea6cc31355d84c2c33e3c935df548f
parent b6ec4ed7517833f60f6515fe3b708e250c33d175
Author: Emmanuel Marty <emmanuel@fgl.com>
Date:   Sat, 10 Oct 2020 12:34:23 +0200

Merge pull request #1 from zhangxinlong633/master

fix buffer overflow
Diffstat:
Mlib/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; + } } }