[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
Thu Nov 7 04:58:02 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("out-of-bound while parsing verdaux entries, corrupted "
+                    "verdef section",
+                    Obj.getFileName());
----------------
jh7370 wrote:

Please rewrite this error to include as much context as possible. In particular, take a look at how llvm-readobj and llvm-objdump describe section names, and include the actual offset and expected offset.

I'd consider something like "vd_aux value xxx in section xxx points past the end of the section at offset xxx", where "xxx" should be replaced with appropriate strings/numbers.

https://github.com/llvm/llvm-project/pull/115284


More information about the llvm-commits mailing list