lz4: Cherrypick fix for CVE-2021-3520

There should be no risk of us accidentally hitting this since
we'd need maliciously malformed data to wind up in the pipeline,
or a very unfortunate random bit flip at exactly the right moment.
Still since we can handle it we should.

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Adam Moss <c@yotes.com>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12947
This commit is contained in:
Rich Ercolani 2022-01-12 19:14:36 -05:00 committed by GitHub
parent d6c1bbdd65
commit 63f4bfd6ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -541,7 +541,7 @@ LZ4_decompress_generic(
const size_t dictSize /* note : = 0 if noDict */ const size_t dictSize /* note : = 0 if noDict */
) )
{ {
if (src == NULL) { return -1; } if ((src == NULL) || (outputSize < 0)) { return -1; }
{ const BYTE* ip = (const BYTE*) src; { const BYTE* ip = (const BYTE*) src;
const BYTE* const iend = ip + srcSize; const BYTE* const iend = ip + srcSize;