harshvardhanrp opened a new pull request, #16791: URL: https://github.com/apache/lucene/pull/16791
### Description <Write 1 to 3 sentences here in your own words. For example: how you found this and why you think it is worth fixing.> > The preset-dict decompressors (LZ4WithPresetDictCompressionMode for BEST_SPEED > and DeflateWithPresetDictCompressionMode for BEST_COMPRESSION) read dictLength > and blockLength from the .fdt file and use them without any checks. > > If these values are broken, reading a stored document can fail badly instead > of throwing CorruptIndexException: > - blockLength = 0 gives "ArithmeticException: / by zero" (LZ4) > - a very large dictLength makes Lucene try to allocate about 2 GB, which gave > OutOfMemoryError from a ~370 byte .fdt file > > This change checks 0 <= dictLength <= originalLength and > 1 <= blockLength <= originalLength right after reading them, and throws > CorruptIndexException otherwise. The compressors always write values inside > these bounds, so valid indexes are not affected. The cost is two integer > comparisons per decompress call. > > Tests: added testCorruptHeader to TestLZ4WithPresetDictCompressionMode and > TestDeflateWithPresetDictCompressionMode. All core codec tests pass > (./gradlew :lucene:core:test --tests "org.apache.lucene.codecs.*"). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
