Skip to content

Commit

Permalink
Fix a range check when reading from ELF files
Browse files Browse the repository at this point in the history
The end address is exclusive, not inclusive. This off-by-one could mean
that we look at the wrong shared library for a given address if it
occurs at the very start of start of a mapping.

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
godlygeek authored and pablogsal committed Feb 13, 2025
1 parent c3ef08a commit 5b75822
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pystack/_pystack/mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ CorefileRemoteMemoryManager::getMemoryLocationFromElf(
off_t* offset_in_file) const
{
auto shared_libs_it = std::find_if(d_shared_libs.cbegin(), d_shared_libs.cend(), [&](auto& map) {
return map.start <= addr && addr <= map.end;
return map.start <= addr && addr < map.end;
});

if (shared_libs_it == d_shared_libs.cend()) {
Expand Down

0 comments on commit 5b75822

Please sign in to comment.