diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b122537..91079ac18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -115,8 +115,10 @@ The table below shows which release corresponds to each branch, and what date th ## 4.14.1 - [#2533][2533] Fix installation on Python 3.5 and lower +- [#2518][2518] fix: update apport coredump path handling for CorefileFinder [2533]: https://github.com/Gallopsled/pwntools/pull/2533 +[2518]: https://github.com/Gallopsled/pwntools/pull/2518 ## 4.14.0 (`stable`) diff --git a/pwnlib/elf/corefile.py b/pwnlib/elf/corefile.py index 1cb8823fa..f092153c1 100644 --- a/pwnlib/elf/corefile.py +++ b/pwnlib/elf/corefile.py @@ -1510,7 +1510,18 @@ def apport_coredump(self): # should be unique enough that we can just glob. boot_id = read('/proc/sys/kernel/random/boot_id').strip().decode() - path = self.exe.replace('/', '_') + + # Use the absolute path of the executable + # Apport uses the executable's path to determine the core dump filename + # + # Reference source: + # https://github.com/canonical/apport/blob/4bbb179b8f92989bf7c1ee3692074f35d70ef3e8/data/apport#L110 + # https://github.com/canonical/apport/blob/4bbb179b8f92989bf7c1ee3692074f35d70ef3e8/apport/fileutils.py#L599 + # + # Apport calls `get_core_path` with `options.executable_path`, which corresponds to + # the executable's pathname, as specified by the `%E` placeholder + # in the core pattern (see `man core` and `apport --help`). + path = os.path.abspath(self.exe).replace('/', '_').replace('.', '_') # Format the name corefile_name = 'core.{path}.{uid}.{boot_id}.{pid}.*'.format(