Skip to content

Commit

Permalink
fix(DyldInfo): Not reading data if size is zero. May happen on arm64e
Browse files Browse the repository at this point in the history
  • Loading branch information
macmade committed Apr 2, 2024
1 parent 6298afb commit 3f4eeac
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions lib-macho/source/LoadCommands/DyldInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,37 @@ namespace MachO
size_t pos( stream.tell() );

( void )kind;

stream.seek( this->_rebaseOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Rebase", stream.read( this->_rebaseSize ) } );

stream.seek( this->_bindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Binding", stream.read( this->_bindingSize ) } );

stream.seek( this->_weakBindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Weak binding", stream.read( this->_weakBindingSize ) } );

stream.seek( this->_lazyBindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Lazy binding", stream.read( this->_lazyBindingSize ) } );

stream.seek( this->_exportOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Export", stream.read( this->_exportSize ) } );


if( this->_rebaseSize != 0 )
{
stream.seek( this->_rebaseOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Rebase", stream.read( this->_rebaseSize ) } );
}

if( this->_bindingSize != 0 )
{
stream.seek( this->_bindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Binding", stream.read( this->_bindingSize ) } );
}

if( this->_weakBindingSize != 0 )
{
stream.seek( this->_weakBindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Weak binding", stream.read( this->_weakBindingSize ) } );
}

if( this->_lazyBindingSize != 0 )
{
stream.seek( this->_lazyBindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Lazy binding", stream.read( this->_lazyBindingSize ) } );
}

if( this->_exportSize != 0 )
{
stream.seek( this->_exportOffset, XS::IO::BinaryStream::SeekDirection::Begin );
this->_data.push_back( { "Export", stream.read( this->_exportSize ) } );
}

stream.seek( pos, XS::IO::BinaryStream::SeekDirection::Begin );
}

Expand Down

0 comments on commit 3f4eeac

Please sign in to comment.