[PATCH] D77216: [llvm-readobj] - Fix crashes and misbehaviors when reading strings from broken string tables.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 01:35:18 PDT 2020


jhenderson added inline comments.


================
Comment at: llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test:375
+
+## Document we do when the dynamic string table ends past the end of the file. Check we do not crash.
+
----------------
Maybe this could be "Check that we emit an appropriate warning when the dynamic string table ends past the end of the file."


================
Comment at: llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test:377
+
+## Case A: the value of DT_STRSZ tag is set so that the string table ends right before the EOF.
+# RUN: yaml2obj %s -DSTRSZ=0x210 --docnum=6 -o %t9.1
----------------
Add "No warning should be emitted." here, I think.


================
Comment at: llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test:384-385
+
+## Note: strings are dumped because the file ends with the zero byte. Code reads the data
+## in [DT_STRTAB, DT_STRTAB + DT_STRSZ] range as a normal null-terminated string table.
+# BEFORE-THE-EOF:      {{[(]?}}NEEDED{{[)]?}}    Shared library: [test.soabc]
----------------
I think if we rewrite this note slightly, we could clarify more that it's not important what the final byte is:

"Note: The code reads the data in [DT_STRTAB, DT_STRTAB + DT_STRSZ] as the string table as normal. Since the file ends with a zero byte, strings are dumped, but if it didn't, we'd get <?> printed instead. The important bit is that we don't get the past the end warning."


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

https://reviews.llvm.org/D77216





More information about the llvm-commits mailing list