File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 55- ** Breaking:** Removed the optional ` unstable ` feature (required nightly)
66 - ` core::error::Error ` is now implemented unconditionally
77- ** Breaking:** The MSRV is now 1.81
8+ - Fixed a bug causing UB in ` ElfSection::name() `
89
910## v0.23.1 (2024-10-21)
1011
Original file line number Diff line number Diff line change @@ -320,12 +320,19 @@ impl ElfSection<'_> {
320320 }
321321
322322 unsafe fn string_table ( & self ) -> * const u8 {
323- let addr = match self . entry_size {
324- 40 => ( * ( self . string_section as * const ElfSectionInner32 ) ) . addr as usize ,
325- 64 => ( * ( self . string_section as * const ElfSectionInner64 ) ) . addr as usize ,
323+ match self . entry_size {
324+ 40 => {
325+ let ptr = self . string_section . cast :: < ElfSectionInner32 > ( ) ;
326+ let reference = unsafe { ptr. as_ref ( ) . unwrap ( ) } ;
327+ reference. addr ( ) as * const u8
328+ }
329+ 64 => {
330+ let ptr = self . string_section . cast :: < ElfSectionInner64 > ( ) ;
331+ let reference = unsafe { ptr. as_ref ( ) . unwrap ( ) } ;
332+ reference. addr ( ) as * const u8
333+ }
326334 s => panic ! ( "Unexpected entry size: {s}" ) ,
327- } ;
328- addr as * const _
335+ }
329336 }
330337}
331338
You can’t perform that action at this time.
0 commit comments