diff options
author | Aleksei Vetrov <vvvvvv@google.com> | 2023-11-23 15:31:47 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2023-11-24 00:15:41 +0100 |
commit | 03c171947cc538b04957ac2222ce86e7c0170bd1 (patch) | |
tree | 9b441eecb18c303b9d0f1f9f893d9cb49a03a7a9 | |
parent | 2f38fa57942f95a9ada35e6802df864747c81cce (diff) |
libelf: check decompressed ZSTD size
Decompression functions like __libelf_decompress_zlib check that
decompressed data has the same size as it was declared in the header
(size_out argument). The same check is now added to
__libelf_decompress_zstd to make sure that the whole allocated buffer is
initialized.
* libelf/elf_compress.c (__libelf_decompress_zstd): Use return value
of ZSTD_decompress to check that decompressed data size is the
same as size_out of the buffer that was allocated.
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
-rw-r--r-- | libelf/elf_compress.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c index c7283c6a..0ad6a32a 100644 --- a/libelf/elf_compress.c +++ b/libelf/elf_compress.c @@ -422,7 +422,7 @@ __libelf_decompress_zstd (void *buf_in, size_t size_in, size_t size_out) } size_t ret = ZSTD_decompress (buf_out, size_out, buf_in, size_in); - if (ZSTD_isError (ret)) + if (unlikely (ZSTD_isError (ret)) || unlikely (ret != size_out)) { free (buf_out); __libelf_seterrno (ELF_E_DECOMPRESS_ERROR); |