From aec101ab06697221d2bc2f82b3a65fb92054ed9f Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 29 Mar 2023 12:45:16 +1030 Subject: [PATCH] Sanity check section size in bfd_init_section_compress_status This function doesn't just initialise for compression, it actually compresses. This patch sanity checks section size before allocating buffers for the uncompressed contents. * compress.c (bfd_init_section_compress_status): Sanity check section size. --- bfd/compress.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bfd/compress.c b/bfd/compress.c index 39f9c50a445..844328b27a9 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -1065,7 +1065,8 @@ bfd_init_section_compress_status (bfd *abfd, sec_ptr sec) || sec->size == 0 || sec->rawsize != 0 || sec->contents != NULL - || sec->compress_status != COMPRESS_SECTION_NONE) + || sec->compress_status != COMPRESS_SECTION_NONE + || _bfd_section_size_insane (abfd, sec)) { bfd_set_error (bfd_error_invalid_operation); return false; -- 2.30.2