Skip to content

Commit b932eb8

Browse files
committed
print-interpreter: fix off by one error
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.
1 parent fbf108f commit b932eb8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ Makefile
3232
/tests/libbig-dynstr.debug
3333
/tests/contiguous-note-sections
3434
/tests/simple-pie
35+
36+
.direnv/
37+
.vscode/
38+
.idea/

src/patchelf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ template<ElfFileParams>
12371237
std::string ElfFile<ElfFileParamNames>::getInterpreter()
12381238
{
12391239
auto shdr = findSection(".interp");
1240-
return std::string((char *) fileContents->data() + rdi(shdr.sh_offset), rdi(shdr.sh_size));
1240+
return std::string((char *) fileContents->data() + rdi(shdr.sh_offset), rdi(shdr.sh_size) - 1);
12411241
}
12421242

12431243
template<ElfFileParams>

0 commit comments

Comments
 (0)