[PATCH] D86422: [ELF] .note.gnu.property: error for invalid pr_datasize
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 01:06:41 PDT 2020
psmith added a comment.
Overall looking good. I think there may be an endianness problem with reinterpret_cast although I could easily be wrong without testing (I don't think we have a target that uses .note.gnu.property with big-endian support in LLD).
================
Comment at: lld/ELF/InputFiles.cpp:795
// Read one NOTE record.
- if (data.size() < sizeof(Elf_Nhdr))
- fatal(toString(obj) + ": .note.gnu.property: section too short");
-
auto *nhdr = reinterpret_cast<const Elf_Nhdr *>(data.data());
+ if (data.size() < sizeof(Elf_Nhdr) || data.size() < nhdr->getSize())
----------------
Will this work if the Host is little endian and the data in big-endian format?
================
Comment at: lld/ELF/InputFiles.cpp:797
+ if (data.size() < sizeof(Elf_Nhdr) || data.size() < nhdr->getSize())
+ reportFatal(data, "data is too short");
----------------
We may be able to be more precise with the size as I think data.size() = sizeof(Elf_Nhdr) + nhdr->getSize()
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86422/new/
https://reviews.llvm.org/D86422
More information about the llvm-commits
mailing list