Skip to content

fix(linux): preserve paths with whitespace in /proc/maps parsing#70

Open
JeanExtreme002 wants to merge 1 commit into
mainfrom
jeanextreme002/fix-linux-maps-path-whitespace
Open

fix(linux): preserve paths with whitespace in /proc/maps parsing#70
JeanExtreme002 wants to merge 1 commit into
mainfrom
jeanextreme002/fix-linux-maps-path-whitespace

Conversation

@JeanExtreme002

Copy link
Copy Markdown
Owner

Fixes #20

The /proc/<pid>/maps parser used line.split() without a limit, which broke pathnames containing whitespace (e.g. /home/user/My Games/game.so).

Changes:

  • Use line.split(maxsplit=5) so the 6th field (pathname) remains intact regardless of spaces
  • .strip() the path to remove the trailing newline that is now preserved by the limited split

@github-actions github-actions Bot added linux Linux backend changes (PyMemoryEditor/linux/) lib Library changes (PyMemoryEditor/) labels Jun 8, 2026
@JeanExtreme002 JeanExtreme002 requested a review from Copilot June 8, 2026 03:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Linux /proc/<pid>/maps parsing so MemoryRegion.path remains intact when the mapped pathname contains whitespace (issue #20), improving correctness of region/module reporting on Linux.

Changes:

  • Switch /proc/<pid>/maps tokenization from unlimited split() to split(maxsplit=5) to preserve the pathname field as a single string even when it contains spaces.
  • Trim the now-preserved trailing newline from the pathname field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 192 to +196
try:
addressing_range, privileges, offset, device, inode = (
region_information[0:5]
)
path = region_information[5] if len(region_information) >= 6 else ""
path = region_information[5].strip() if len(region_information) >= 6 else ""
with mapping_file:
for line in mapping_file:
region_information = line.split()
region_information = line.split(maxsplit=5)
Limit split() to 5 fields so the pathname (6th field) remains intact
even when it contains spaces. Also strip trailing newline from the path.

Fixes #20
@JeanExtreme002 JeanExtreme002 force-pushed the jeanextreme002/fix-linux-maps-path-whitespace branch from b1168b6 to 693f21a Compare June 8, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib Library changes (PyMemoryEditor/) linux Linux backend changes (PyMemoryEditor/linux/)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory Regions' reported paths break when the path contains whitespaces (Linux)

2 participants