[PATCH] D127369: [Object][COFF] Fix section name parsing error when the name field is not null-padded

Pengxuan Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 9 18:46:37 PDT 2022


pzheng added inline comments.


================
Comment at: llvm/lib/Object/COFFObjectFile.cpp:1171
     } else {
-      if (Name.substr(1).getAsInteger(10, Offset))
         return createStringError(object_error::parse_failed,
----------------
pzheng wrote:
> rnk wrote:
> > I think it's a bug that getAsInteger doesn't work on non-null terminated StringRefs. It's not an invariant that StringRefs are null terminated. We explicitly form a non-null terminated StringRef on line 1161 above.
> hmm..., not sure if getAsInteger is supposed to handle a situation like this, the description of the function isn't very clear, but I tend to agree with you that this could be bug unless there are already code in LLVM which assumes getAsInteger should fail given such input.
Looking at the implementation of getAsInteger, it looks like it's actually supposed to fail with such input where only the first part of it is a valid integer. getAsInteger requires the whole string to be consumed or else it's considered as a failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127369



More information about the llvm-commits mailing list