Skip to content

Commit 3f4eeac

Browse files
committed
fix(DyldInfo): Not reading data if size is zero. May happen on arm64e
1 parent 6298afb commit 3f4eeac

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

lib-macho/source/LoadCommands/DyldInfo.cpp

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -187,22 +187,37 @@ namespace MachO
187187
size_t pos( stream.tell() );
188188

189189
( void )kind;
190-
191-
stream.seek( this->_rebaseOffset, XS::IO::BinaryStream::SeekDirection::Begin );
192-
this->_data.push_back( { "Rebase", stream.read( this->_rebaseSize ) } );
193-
194-
stream.seek( this->_bindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
195-
this->_data.push_back( { "Binding", stream.read( this->_bindingSize ) } );
196-
197-
stream.seek( this->_weakBindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
198-
this->_data.push_back( { "Weak binding", stream.read( this->_weakBindingSize ) } );
199-
200-
stream.seek( this->_lazyBindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
201-
this->_data.push_back( { "Lazy binding", stream.read( this->_lazyBindingSize ) } );
202-
203-
stream.seek( this->_exportOffset, XS::IO::BinaryStream::SeekDirection::Begin );
204-
this->_data.push_back( { "Export", stream.read( this->_exportSize ) } );
205-
190+
191+
if( this->_rebaseSize != 0 )
192+
{
193+
stream.seek( this->_rebaseOffset, XS::IO::BinaryStream::SeekDirection::Begin );
194+
this->_data.push_back( { "Rebase", stream.read( this->_rebaseSize ) } );
195+
}
196+
197+
if( this->_bindingSize != 0 )
198+
{
199+
stream.seek( this->_bindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
200+
this->_data.push_back( { "Binding", stream.read( this->_bindingSize ) } );
201+
}
202+
203+
if( this->_weakBindingSize != 0 )
204+
{
205+
stream.seek( this->_weakBindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
206+
this->_data.push_back( { "Weak binding", stream.read( this->_weakBindingSize ) } );
207+
}
208+
209+
if( this->_lazyBindingSize != 0 )
210+
{
211+
stream.seek( this->_lazyBindingOffset, XS::IO::BinaryStream::SeekDirection::Begin );
212+
this->_data.push_back( { "Lazy binding", stream.read( this->_lazyBindingSize ) } );
213+
}
214+
215+
if( this->_exportSize != 0 )
216+
{
217+
stream.seek( this->_exportOffset, XS::IO::BinaryStream::SeekDirection::Begin );
218+
this->_data.push_back( { "Export", stream.read( this->_exportSize ) } );
219+
}
220+
206221
stream.seek( pos, XS::IO::BinaryStream::SeekDirection::Begin );
207222
}
208223

0 commit comments

Comments
 (0)