Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Support] Check zstd decompress result before msan unpoison #117276

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions llvm/lib/Support/Compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,13 @@ Error zstd::decompress(ArrayRef<uint8_t> Input, uint8_t *Output,
const size_t Res = ::ZSTD_decompress(
Output, UncompressedSize, (const uint8_t *)Input.data(), Input.size());
UncompressedSize = Res;
if (ZSTD_isError(Res))
return make_error<StringError>(ZSTD_getErrorName(Res),
inconvertibleErrorCode());
// Tell MemorySanitizer that zstd output buffer is fully initialized.
// This avoids a false report when running LLVM with uninstrumented ZLib.
__msan_unpoison(Output, UncompressedSize);
return ZSTD_isError(Res) ? make_error<StringError>(ZSTD_getErrorName(Res),
inconvertibleErrorCode())
: Error::success();
return Error::success();
}

Error zstd::decompress(ArrayRef<uint8_t> Input,
Expand Down
Loading