Skip to content

Commit

Permalink
Revert "Revert "Track permissions as bytes""
Browse files Browse the repository at this point in the history
This reverts commit 9bc29a0.
  • Loading branch information
workingjubilee committed Jul 7, 2023
1 parent 268a18d commit dca80ea
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/symbolize/gimli/parse_running_mmaps_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(super) struct MapsEntry {
/// x = execute
/// s = shared
/// p = private (copy on write)
perms: [char; 4],
// perms: [u8; 4],
/// Offset into the file (or "whatever").
// offset: usize,
/// device (major, minor)
Expand Down Expand Up @@ -105,14 +105,12 @@ impl FromStr for MapsEntry {
} 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 _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 _offset = hex(offset_str)?;
let _dev = if let Some((major, minor)) = dev_str.split_once(':') {
Expand All @@ -125,7 +123,7 @@ impl FromStr for MapsEntry {

Ok(MapsEntry {
address,
perms,
// perms,
// offset,
// dev,
// inode,
Expand All @@ -145,7 +143,7 @@ fn check_maps_entry_parsing_64bit() {
.unwrap(),
MapsEntry {
address: (0xffffffffff600000, 0xffffffffff601000),
perms: ['-', '-', 'x', 'p'],
// perms: *b"--xp",
// offset: 0x00000000,
// dev: (0x00, 0x00),
// inode: 0x0,
Expand All @@ -160,7 +158,7 @@ fn check_maps_entry_parsing_64bit() {
.unwrap(),
MapsEntry {
address: (0x7f5985f46000, 0x7f5985f48000),
perms: ['r', 'w', '-', 'p'],
// perms: *b"rw-p",
// offset: 0x00039000,
// dev: (0x103, 0x06),
// inode: 0x76021795,
Expand All @@ -173,7 +171,7 @@ fn check_maps_entry_parsing_64bit() {
.unwrap(),
MapsEntry {
address: (0x35b1a21000, 0x35b1a22000),
perms: ['r', 'w', '-', 'p'],
// perms: *b"rw-p",
// offset: 0x00000000,
// dev: (0x00, 0x00),
// inode: 0x0,
Expand All @@ -197,7 +195,7 @@ fn check_maps_entry_parsing_32bit() {
.unwrap(),
MapsEntry {
address: (0x08056000, 0x08077000),
perms: ['r', 'w', '-', 'p'],
// perms: *b"rw-p",
// offset: 0x00000000,
// dev: (0x00, 0x00),
// inode: 0x0,
Expand All @@ -212,7 +210,7 @@ fn check_maps_entry_parsing_32bit() {
.unwrap(),
MapsEntry {
address: (0xb7c79000, 0xb7e02000),
perms: ['r', '-', '-', 'p'],
// perms: *b"r--p",
// offset: 0x00000000,
// dev: (0x08, 0x01),
// inode: 0x60662705,
Expand All @@ -225,7 +223,7 @@ fn check_maps_entry_parsing_32bit() {
.unwrap(),
MapsEntry {
address: (0xb7e02000, 0xb7e03000),
perms: ['r', 'w', '-', 'p'],
// perms: *b"rw-p",
// offset: 0x00000000,
// dev: (0x00, 0x00),
// inode: 0x0,
Expand Down

0 comments on commit dca80ea

Please sign in to comment.