Skip to content

Commit

Permalink
check that stream is big enough, accounting for overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Agun authored and serge1 committed Jun 5, 2024
1 parent 0d10af1 commit 1b1bd73
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion elfio/elfio_section.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ template <class T> 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 ) ) {
Expand Down

0 comments on commit 1b1bd73

Please sign in to comment.