[PATCH] D50387: [WASM] Fix overflow when reading custom section
Jonas Devlieghere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 7 11:48:27 PDT 2018
JDevlieghere added inline comments.
================
Comment at: llvm/lib/Object/WasmObjectFile.cpp:222
+ const uint32_t NameLength = Ctx.Ptr - NameStart;
+ if (NameLength > Size)
+ return make_error<StringError>(
----------------
sbc100 wrote:
> JDevlieghere wrote:
> > Can this section be empty? (i.e. should I make this greater or equal)
> I think the ReadContext is probably a better way to enforce this. readString already does this check based on the context.
>
> This check seems a little strange since it reads the string before checking if its too long.
>
I started out by doing that that but then you still have to update the current pointer and the size which made the code less intuitive. That combined with a less readable error message made me go this route. I'm happy to change it if you still think the ReadContext is better given the context. (pun not intended :-)
Repository:
rL LLVM
https://reviews.llvm.org/D50387
More information about the llvm-commits
mailing list