From 92b9b67df6e3676f81415882760d9ec8939219e9 Mon Sep 17 00:00:00 2001 From: Michael Agun Date: Tue, 4 Jun 2024 09:23:57 -0700 Subject: [PATCH] check that stream is big enough, accounting for overflow --- elfio/elfio_section.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfio/elfio_section.hpp b/elfio/elfio_section.hpp index f08b585..4be0b97 100644 --- a/elfio/elfio_section.hpp +++ b/elfio/elfio_section.hpp @@ -285,7 +285,7 @@ template class section_impl : public section Elf_Xword size = get_size(); if ( nullptr == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() && - ( sh_offset + size ) <= get_stream_size() ) { + sh_offset <= get_stream_size() && size <= (get_stream_size() - sh_offset)) { data.reset( new ( std::nothrow ) char[size_t( size ) + 1] ); if ( ( 0 != size ) && ( nullptr != data ) ) {