[WebAssembly] Fix validation of start function

The check for valid start function was inverted.  Added a new
test in test/Object to check this case and fixed the existing
tests in for ObjectYAML.

Differential Revision: https://reviews.llvm.org/D32986

llvm-svn: 302560
This commit is contained in:
Sam Clegg
2017-05-09 17:51:38 +00:00
parent 073c4e66b0
commit a0efcfe92b
4 changed files with 21 additions and 4 deletions

View File

@@ -507,7 +507,7 @@ Error WasmObjectFile::parseExportSection(const uint8_t *Ptr, const uint8_t *End)
Error WasmObjectFile::parseStartSection(const uint8_t *Ptr, const uint8_t *End) {
StartFunction = readVaruint32(Ptr);
if (StartFunction < FunctionTypes.size())
if (StartFunction >= FunctionTypes.size())
return make_error<GenericBinaryError>("Invalid start function",
object_error::parse_failed);
return Error::success();