From b932eb870012bb07490faecc1a1cbc5003848727 Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Sat, 18 Dec 2021 06:08:45 -0800 Subject: [PATCH] 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 (#357) since there was an additional '\0' and the strings would not concatenate as a result. --- .gitignore | 4 ++++ src/patchelf.cc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 39713810..921b9f85 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,7 @@ Makefile /tests/libbig-dynstr.debug /tests/contiguous-note-sections /tests/simple-pie + +.direnv/ +.vscode/ +.idea/ diff --git a/src/patchelf.cc b/src/patchelf.cc index 1aeae88f..eaf2a42f 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -1237,7 +1237,7 @@ template std::string ElfFile::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