[PATCH] D107398: [llvm-readobj][XCOFF] Warn about invalid offset
Esme Yi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 4 01:41:59 PDT 2021
Esme updated this revision to Diff 364004.
Esme added a comment.
Add an early out if the string list is empty.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107398/new/
https://reviews.llvm.org/D107398
Files:
llvm/tools/llvm-readobj/ObjDumper.cpp
Index: llvm/tools/llvm-readobj/ObjDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ObjDumper.cpp
+++ llvm/tools/llvm-readobj/ObjDumper.cpp
@@ -54,10 +54,16 @@
void ObjDumper::printAsStringList(StringRef StringContent,
size_t StringDataOffset) {
- if (StringContent.size() < StringDataOffset) {
- reportUniqueWarning("error: offset is out of string contents");
+ size_t StrSize = StringContent.size();
+ if (!StrSize)
+ return;
+ if (StrSize < StringDataOffset) {
+ reportUniqueWarning("offset (0x" + Twine::utohexstr(StringDataOffset) +
+ ") is past the end of the contents size (0x" +
+ Twine::utohexstr(StrSize) + ")");
return;
}
+
const uint8_t *StrContent = StringContent.bytes_begin();
// Some formats contain additional metadata at the start which should not be
// interpreted as strings. Skip these bytes, but account for them in the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107398.364004.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210804/343a05aa/attachment.bin>
More information about the llvm-commits
mailing list