[PATCH] D62898: [llvm-objcopy] - Emit error and don't crash if program header reaches past end of file.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 05:39:16 PDT 2019


jhenderson added inline comments.


================
Comment at: test/tools/llvm-objcopy/ELF/invalid-p_filesz.test:7
+# RUN: not llvm-objcopy %t.o 2>&1 | FIleCheck %s
+# CHECK: error: program header at offset 440 of size 1048576 is mailformed.
+
----------------
Could the numbers be in hex? I feel like those are more natural.

Also, there are a couple of typos. 1) FIleCheck has a capital 'I' in it spuriously, and "mailformed" should be "malformed".

I'd probably change the message slightly to say "with offset 0x1234 and file size ..." (because the program header is not at an offset, it has an offset field, and there are two sizes in program headers).


================
Comment at: test/tools/llvm-objcopy/ELF/invalid-p_filesz.test:20
+  - Type:        PT_LOAD
+    FileSize:    0x100000
+    Sections:    
----------------
I think we need another test case here, where the file offset is outside the file entirely.


================
Comment at: tools/llvm-objcopy/ELF/Object.cpp:1109
+      error("program header at offset " + Twine(Phdr.p_offset) + " of size " +
+            Twine(Phdr.p_filesz) + " is mailformed");
+
----------------
mailformed -> malformed (as noted above).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62898/new/

https://reviews.llvm.org/D62898





More information about the llvm-commits mailing list