Skip to content

Commit b2345f2

Browse files
fix: update apport coredump path handling for CorefileFinder (#2518)
* fix: update apport coredump path handling for CorefileFinder * chore: update comment on Apport core path handling * Update CHANGELOG --------- Co-authored-by: Peace-Maker <[email protected]>
1 parent e9d9bd9 commit b2345f2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ The table below shows which release corresponds to each branch, and what date th
115115
## 4.14.1
116116

117117
- [#2533][2533] Fix installation on Python 3.5 and lower
118+
- [#2518][2518] fix: update apport coredump path handling for CorefileFinder
118119

119120
[2533]: https://github.com/Gallopsled/pwntools/pull/2533
121+
[2518]: https://github.com/Gallopsled/pwntools/pull/2518
120122

121123
## 4.14.0 (`stable`)
122124

pwnlib/elf/corefile.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,18 @@ def apport_coredump(self):
15101510
# should be unique enough that we can just glob.
15111511

15121512
boot_id = read('/proc/sys/kernel/random/boot_id').strip().decode()
1513-
path = self.exe.replace('/', '_')
1513+
1514+
# Use the absolute path of the executable
1515+
# Apport uses the executable's path to determine the core dump filename
1516+
#
1517+
# Reference source:
1518+
# https://github.com/canonical/apport/blob/4bbb179b8f92989bf7c1ee3692074f35d70ef3e8/data/apport#L110
1519+
# https://github.com/canonical/apport/blob/4bbb179b8f92989bf7c1ee3692074f35d70ef3e8/apport/fileutils.py#L599
1520+
#
1521+
# Apport calls `get_core_path` with `options.executable_path`, which corresponds to
1522+
# the executable's pathname, as specified by the `%E` placeholder
1523+
# in the core pattern (see `man core` and `apport --help`).
1524+
path = os.path.abspath(self.exe).replace('/', '_').replace('.', '_')
15141525

15151526
# Format the name
15161527
corefile_name = 'core.{path}.{uid}.{boot_id}.{pid}.*'.format(

0 commit comments

Comments
 (0)