mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1243239 - Baldr: tighten signature index check (r=bbouvier)
--HG-- extra : commitid : 34c7qVI67Q1
This commit is contained in:
parent
d8112ef98f
commit
8a59303f0c
@ -312,7 +312,7 @@ DecodeDeclarationSection(JSContext* cx, Decoder& d, ModuleGeneratorData* init)
|
||||
if (!d.readVarU32(&sigIndex))
|
||||
return Fail(cx, d, "expected declaration signature index");
|
||||
|
||||
if (sigIndex > init->sigs.length())
|
||||
if (sigIndex >= init->sigs.length())
|
||||
return Fail(cx, d, "declaration signature index out of range");
|
||||
|
||||
init->funcSigs[i] = &init->sigs[sigIndex];
|
||||
|
@ -108,3 +108,15 @@ wasmEval(toBuf(moduleWithSections([sigSection([{args:[I32Code], ret:VoidCode}])]
|
||||
|
||||
assertErrorMessage(() => wasmEval(toBuf(moduleWithSections([sigSection([{args:[], ret:100}])]))), Error, /bad expression type/);
|
||||
assertErrorMessage(() => wasmEval(toBuf(moduleWithSections([sigSection([{args:[100], ret:VoidCode}])]))), Error, /bad value type/);
|
||||
|
||||
function declSection(decls) {
|
||||
var body = [];
|
||||
body.push(...varU32(decls.length));
|
||||
for (var decl of decls)
|
||||
body.push(...varU32(decl));
|
||||
return { name: declSectionStr, body };
|
||||
}
|
||||
|
||||
assertThrowsInstanceOf(() => wasmEval(toBuf(moduleWithSections([sigSection([]), declSection([0])]))), Error, /signature index out of range/);
|
||||
assertThrowsInstanceOf(() => wasmEval(toBuf(moduleWithSections([sigSection([{args:[], ret:VoidCode}]), declSection([1])]))), Error, /signature index out of range/);
|
||||
wasmEval(toBuf(moduleWithSections([sigSection([{args:[], ret:VoidCode}]), declSection([0])])));
|
||||
|
Loading…
Reference in New Issue
Block a user