Skip to content

Commit

Permalink
print-interpreter: fix off by one error
Browse files Browse the repository at this point in the history
Fix off by one error in the code that reads interpreter from the ELF
file. This was not evident when it was written directly to STDOUT but
became problematic through my exploration of new functionality (NixOS#357)
since there was an additional '\0' and the strings would not concatenate
as a result.
  • Loading branch information
fzakaria committed Dec 18, 2021
1 parent fbf108f commit b932eb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ Makefile
/tests/libbig-dynstr.debug
/tests/contiguous-note-sections
/tests/simple-pie

.direnv/
.vscode/
.idea/
2 changes: 1 addition & 1 deletion src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ template<ElfFileParams>
std::string ElfFile<ElfFileParamNames>::getInterpreter()
{
auto shdr = findSection(".interp");
return std::string((char *) fileContents->data() + rdi(shdr.sh_offset), rdi(shdr.sh_size));
return std::string((char *) fileContents->data() + rdi(shdr.sh_offset), rdi(shdr.sh_size) - 1);
}

template<ElfFileParams>
Expand Down

0 comments on commit b932eb8

Please sign in to comment.