Skip to content

Commit ae3902a

Browse files
Validation: Check function type index bounds in import entry
1 parent 673fe9d commit ae3902a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/WasmKit/Execution/StoreAllocator.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ extension StoreAllocator {
277277
switch (importEntry.descriptor, external) {
278278
case let (.function(typeIndex), .function(externalFunc)):
279279
let type = externalFunc.type
280+
guard typeIndex < module.types.count else {
281+
throw ValidationError("Function type index out of bounds")
282+
}
280283
guard engine.internType(module.types[Int(typeIndex)]) == type else {
281284
throw ImportError.incompatibleImportType
282285
}

Tests/WasmKitTests/SpectestTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ final class SpectestTests: XCTestCase {
2222
path: Self.testPaths,
2323
include: [],
2424
exclude: [
25-
"func.wast",
26-
"func_ptrs.wast",
2725
"global.wast",
2826
"if.wast",
2927
"imports.wast",

0 commit comments

Comments
 (0)