Fix Data Corruption Bug when Streaming with an Attached Dict in HC Mode
authorW. Felix Handte <w@felixhandte.com>
Thu, 18 Jul 2019 16:41:12 +0000 (12:41 -0400)
committerW. Felix Handte <w@felixhandte.com>
Thu, 18 Jul 2019 16:48:41 +0000 (12:48 -0400)
commit369fb3900cbc73543f1bab276ca1b82abe402937
tree0f4dbe09c6a21166a4fe2e4908c66e3fb85a13a0
parent19b099986aeccc12bb46ad207fe8de5b36bdb7bc
Fix Data Corruption Bug when Streaming with an Attached Dict in HC Mode

This diff fixes an issue in which we failed to clear the `dictCtx` in HC
compression. The `dictCtx` is not supposed to be used when an `extDict` is
present: matches found in the `dictCtx` do not account for the presence of an
`extDict` segment, and their offsets are therefore miscalculated when one is
present. This can lead to data corruption.

This diff clears the `dictCtx` whenever setting an `extDict`.

This issue was uncovered by @terrelln's fuzzing work.
lib/lz4hc.c