Skip to content

Commit

Permalink
Revert "Track permissions as bytes"
Browse files Browse the repository at this point in the history
This reverts commit 25bddbf.
  • Loading branch information
workingjubilee committed Jul 7, 2023
1 parent 6a05e64 commit 9bc29a0
Showing 1 changed file with 16 additions and 14 deletions.
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 @@ -18,7 +18,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: usize,
/// device (major, minor)
Expand Down Expand Up @@ -105,12 +105,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 @@ -123,7 +125,7 @@ impl FromStr for MapsEntry {

Ok(MapsEntry {
address,
// perms,
perms,
// offset,
// dev,
// inode,
Expand All @@ -143,7 +145,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 @@ -158,7 +160,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 @@ -171,7 +173,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 @@ -195,7 +197,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 @@ -210,7 +212,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 @@ -223,7 +225,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

0 comments on commit 9bc29a0

Please sign in to comment.