Skip to content

Track permissions as bytes #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Track permissions as bytes"
This reverts commit 25bddbf.
  • Loading branch information
workingjubilee committed Jan 6, 2025
commit 80420cb87eea08139d41409669830384dad78073
30 changes: 16 additions & 14 deletions src/symbolize/gimli/parse_running_mmaps_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(super) struct MapsEntry {
/// x = execute
/// s = shared
/// p = private (copy on write)
// perms: [u8; 4],
perms: [char; 4],
/// Offset into the file (or "whatever").
// offset: u64,
/// device (major, minor)
Expand Down Expand Up @@ -115,12 +115,14 @@ impl FromStr for MapsEntry {
} else {
return Err(parse_err);
};
let _perms = if let &[r, w, x, p, ..] = perms_str.as_bytes() {
// If a system in the future adds a 5th field to the permission list,
// there's no reason to assume previous fields were invalidated.
[r, w, x, p]
} else {
return Err(parse_err);
let perms: [char; 4] = {
let mut chars = perms_str.chars();
let mut c = || chars.next().ok_or("insufficient perms");
let perms = [c()?, c()?, c()?, c()?];
if chars.next().is_some() {
return Err("too many perms");
}
perms
};
let _offset = hex(offset_str)?;
let _dev = if let Some((major, minor)) = dev_str.split_once(':') {
Expand All @@ -133,7 +135,7 @@ impl FromStr for MapsEntry {

Ok(MapsEntry {
address,
// perms,
perms,
// offset,
// dev,
// inode,
Expand All @@ -153,7 +155,7 @@ fn check_maps_entry_parsing_64bit() {
.unwrap(),
MapsEntry {
address: (0xffffffffff600000, 0xffffffffff601000),
// perms: *b"--xp",
perms: ['-', '-', 'x', 'p'],
// offset: 0x00000000,
// dev: (0x00, 0x00),
// inode: 0x0,
Expand All @@ -168,7 +170,7 @@ fn check_maps_entry_parsing_64bit() {
.unwrap(),
MapsEntry {
address: (0x7f5985f46000, 0x7f5985f48000),
// perms: *b"rw-p",
perms: ['r', 'w', '-', 'p'],
// offset: 0x00039000,
// dev: (0x103, 0x06),
// inode: 0x76021795,
Expand All @@ -181,7 +183,7 @@ fn check_maps_entry_parsing_64bit() {
.unwrap(),
MapsEntry {
address: (0x35b1a21000, 0x35b1a22000),
// perms: *b"rw-p",
perms: ['r', 'w', '-', 'p'],
// offset: 0x00000000,
// dev: (0x00, 0x00),
// inode: 0x0,
Expand All @@ -205,7 +207,7 @@ fn check_maps_entry_parsing_32bit() {
.unwrap(),
MapsEntry {
address: (0x08056000, 0x08077000),
// perms: *b"rw-p",
perms: ['r', 'w', '-', 'p'],
// offset: 0x00000000,
// dev: (0x00, 0x00),
// inode: 0x0,
Expand All @@ -220,7 +222,7 @@ fn check_maps_entry_parsing_32bit() {
.unwrap(),
MapsEntry {
address: (0xb7c79000, 0xb7e02000),
// perms: *b"r--p",
perms: ['r', '-', '-', 'p'],
// offset: 0x00000000,
// dev: (0x08, 0x01),
// inode: 0x60662705,
Expand All @@ -233,7 +235,7 @@ fn check_maps_entry_parsing_32bit() {
.unwrap(),
MapsEntry {
address: (0xb7e02000, 0xb7e03000),
// perms: *b"rw-p",
perms: ['r', 'w', '-', 'p'],
// offset: 0x00000000,
// dev: (0x00, 0x00),
// inode: 0x0,
Expand Down