[llvm] [llvm-objdump][ELF] Ensure offset to verdaux entry array does not go past size (PR #115284)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 04:02:32 PST 2024
================
@@ -398,6 +401,12 @@ static void printSymbolVersionDefinition(const typename ELFT::Shdr &Shdr,
<< format("0x%08" PRIx32 " ", (uint32_t)Verdef->vd_hash);
const uint8_t *BufAux = Buf + Verdef->vd_aux;
+ if (BufAux > Contents.end()) {
+ reportWarning("corrupted section: vd_aux value " + Twine(Verdef->vd_aux) +
+ " in section verdef points past end of the section",
+ Obj.getFileName());
----------------
jh7370 wrote:
> I went with 'vd_aux value %val in section verdef points past end of the section, corrupted section,' as I don't think it’s that relevant to provide the exact byte count by which the aux entry went out of bounds. I added 'corrupted section' consistently with the other warnings.
I just searched for the string "corrupted section" and haven't found any relevant reference. What other warnings are you trying to be consistent with?
Please use the `describe` method (in Object\ELF.h) in place of "in section verdef" to be consistent with other recent messages added/changed in llvm-readelf.
The idea of including the section size is that it could be the size that is malformed, not the vd_aux value (for whatever reason). ELFDumper.cpp in llvm-readelf has a number of examples of this sort of message pattern (search for "past the end"). There may be others too.
https://github.com/llvm/llvm-project/pull/115284
More information about the llvm-commits
mailing list