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 5
5
- ** Breaking:** Removed the optional ` unstable ` feature (required nightly)
6
6
- ` core::error::Error ` is now implemented unconditionally
7
7
- ** Breaking:** The MSRV is now 1.81
8
+ - Fixed a bug causing UB in ` ElfSection::name() `
8
9
9
10
## v0.23.1 (2024-10-21)
10
11
Original file line number Diff line number Diff line change @@ -320,12 +320,19 @@ impl ElfSection<'_> {
320
320
}
321
321
322
322
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
+ }
326
334
s => panic ! ( "Unexpected entry size: {}" , s) ,
327
- } ;
328
- addr as * const _
335
+ }
329
336
}
330
337
}
331
338
You can’t perform that action at this time.
0 commit comments