fix(linux): preserve paths with whitespace in /proc/maps parsing#70
Open
JeanExtreme002 wants to merge 1 commit into
Open
fix(linux): preserve paths with whitespace in /proc/maps parsing#70JeanExtreme002 wants to merge 1 commit into
JeanExtreme002 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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>/mapstokenization from unlimitedsplit()tosplit(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
b1168b6 to
693f21a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20
The
/proc/<pid>/mapsparser usedline.split()without a limit, which broke pathnames containing whitespace (e.g./home/user/My Games/game.so).Changes:
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