aboutsummaryrefslogtreecommitdiff
path: root/bfd/compress.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-03-29 12:45:16 +1030
committerAlan Modra <amodra@gmail.com>2023-03-29 12:56:46 +1030
commitaec101ab06697221d2bc2f82b3a65fb92054ed9f (patch)
tree2afb1d407031c1dd3aa4ee6b2fa729c53d02f2d8 /bfd/compress.c
parent647744420e69bf5fc8f5ab88a9d7dabd6087a890 (diff)
downloadgdb-aec101ab06697221d2bc2f82b3a65fb92054ed9f.zip
gdb-aec101ab06697221d2bc2f82b3a65fb92054ed9f.tar.gz
gdb-aec101ab06697221d2bc2f82b3a65fb92054ed9f.tar.bz2
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.
Diffstat (limited to 'bfd/compress.c')
-rw-r--r--bfd/compress.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bfd/compress.c b/bfd/compress.c
index 39f9c50..844328b 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;