From: Aleksei Vetrov <vvvvvv@google.com>
To: elfutils-devel@sourceware.org
Cc: kernel-team@android.com, maennich@google.com, vvvvvv@google.com
Subject: [PATCH] libelf: check decompressed ZSTD size
Date: Thu, 23 Nov 2023 15:31:47 +0000 [thread overview]
Message-ID: <20231123153147.537151-1-vvvvvv@google.com> (raw)
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>
---
libelf/elf_compress.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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);
--
2.43.0.rc1.413.gea7ed67945-goog
next reply other threads:[~2023-11-23 15:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 15:31 Aleksei Vetrov [this message]
2023-11-23 23:32 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231123153147.537151-1-vvvvvv@google.com \
--to=vvvvvv@google.com \
--cc=elfutils-devel@sourceware.org \
--cc=kernel-team@android.com \
--cc=maennich@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).