Skip to content

Commit

Permalink
fix: don't panic find_section without procfs
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy committed Nov 5, 2024
1 parent b827f5e commit 69e4913
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,14 @@ mod elf {
use std::io::SeekFrom;

pub fn find_section(name: &str) -> Option<&[u8]> {
let exe = std::env::current_exe().unwrap();
let Ok(exe) = std::env::current_exe() else {
return None;
};

let Ok(mut file) = std::fs::File::open(exe) else {
return None;
};

let mut file = std::fs::File::open(exe).unwrap();
file.seek(SeekFrom::End(-12)).unwrap();
let mut buf = [0; 12];
file.read_exact(&mut buf).unwrap();
Expand Down

0 comments on commit 69e4913

Please sign in to comment.