Skip to content

Commit 6e4e832

Browse files
RaccoonAndrea BURESI-LANG
authored andcommitted
Fix poll error in process.libs() and clean up maps parsing
1 parent 1205b1a commit 6e4e832

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,12 @@ The table below shows which release corresponds to each branch, and what date th
146146
- [#2545][2545] SSH: fix download/upload with -1 exit status
147147
- [#2567][2567] Fix mistakenly parsing of ld-linux error messages.
148148
- [#2576][2576] regsort: respect register aliases
149+
- [#2579][2579] Fix poll error in `process.libs()` and clean up maps parsing
149150

150151
[2545]: https://github.com/Gallopsled/pwntools/pull/2545
151152
[2567]: https://github.com/Gallopsled/pwntools/pull/2567
152153
[2576]: https://github.com/Gallopsled/pwntools/pull/2576
154+
[2579]: https://github.com/Gallopsled/pwntools/pull/2579
153155

154156
## 4.14.1 (`stable`)
155157

pwnlib/tubes/process.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,8 +1322,7 @@ def libs(self):
13221322
by the process to the address it is loaded at in the process' address
13231323
space.
13241324
"""
1325-
from pwnlib.util.proc import memory_maps
1326-
maps_raw = self.poll() is not None and memory_maps(self.pid)
1325+
maps_raw = self.poll() is None and self.maps()
13271326

13281327
if not maps_raw:
13291328
import pwnlib.elf.elf
@@ -1332,23 +1331,15 @@ def libs(self):
13321331
return pwnlib.elf.elf.ELF(self.executable).maps
13331332

13341333
# Enumerate all of the libraries actually loaded right now.
1335-
maps = {}
1334+
libs = {}
13361335
for mapping in maps_raw:
13371336
path = mapping.path
13381337
if os.sep not in path: continue
13391338
path = os.path.realpath(path)
1340-
if path not in maps:
1341-
maps[path]=0
1342-
1343-
for lib in maps:
1344-
path = os.path.realpath(lib)
1345-
for mapping in maps_raw:
1346-
if mapping.path == path:
1347-
address = mapping.addr.split('-')[0]
1348-
maps[lib] = int(address, 16)
1349-
break
1339+
if path not in libs:
1340+
libs[path] = mapping.addr
13501341

1351-
return maps
1342+
return libs
13521343

13531344
@property
13541345
def libc(self):

0 commit comments

Comments
 (0)