zstd icon indicating copy to clipboard operation
zstd copied to clipboard

Undefined behavior in ZSTD_decompressStream()

Open embg opened this issue 3 years ago • 0 comments

When ZSTD_decompressStream() is called with outBuffer == {NULL, 0, 0}, there is undefined behavior here when 0 is added to the NULL outBuffer pointer. UBSAN reports this as "runtime error: applying zero offset to null pointer". It was discovered by folly's CompressionTest.cpp.

Creating this issue to track the following work:

  • Add a test to zstd's CI which exposes the UB.
  • Refactor ZSTD_decompressStream() to avoid the UB.

Note: there is no need to raise an error since the input itself is legal.

embg avatar Aug 07 '22 22:08 embg