File tree Expand file tree Collapse file tree 1 file changed +8
-23
lines changed
Expand file tree Collapse file tree 1 file changed +8
-23
lines changed Original file line number Diff line number Diff line change @@ -219,30 +219,15 @@ impl<'a> TlsData<'a> {
219219 // VA to RVA
220220 let rva = itd. start_address_of_raw_data - image_base;
221221 let size = itd. end_address_of_raw_data - itd. start_address_of_raw_data ;
222- let offset = utils:: find_offset ( rva as usize , sections, file_alignment, opts)
223- . ok_or_else ( || {
224- error:: Error :: Malformed ( format ! (
225- "cannot map tls start_address_of_raw_data rva ({:#x}) into offset" ,
226- rva
227- ) )
228- } ) ?;
229-
230- let offset_end = offset. checked_add ( size as usize ) . ok_or_else ( || {
231- error:: Error :: Malformed ( format ! (
232- "tls start_address_of_raw_data ({:#x}) + size_of_raw_data ({:#x}) casues an integer overflow" ,
233- offset, size
234- ) )
235- } ) ?;
222+ let offset = utils:: find_offset ( rva as usize , sections, file_alignment, opts) ;
236223
237- if offset > bytes. len ( ) || offset_end > bytes. len ( ) {
238- return Err ( error:: Error :: Malformed ( format ! (
239- "tls raw data offset ({:#x}) and size ({:#x}) greater than byte slice len ({:#x})" ,
240- offset,
241- size,
242- bytes. len( )
243- ) ) ) ;
244- }
245- raw_data = Some ( & bytes[ offset..offset + size as usize ] ) ;
224+ raw_data = offset. and_then ( |offset| {
225+ if offset < bytes. len ( ) {
226+ ( & bytes[ offset..] ) . pread_with ( 0 , size as usize ) . ok ( )
227+ } else {
228+ None
229+ }
230+ } ) ;
246231 }
247232
248233 // Parse the index if any
You can’t perform that action at this time.
0 commit comments