(fix): #8408 fixes a bug where the capacity of the buffer isnt verified before trying to verify the ID (#8413)

This commit is contained in:
mustiikhalil
2024-10-05 00:16:41 +02:00
committed by GitHub
parent b127c57ff0
commit d7a70db6ac
3 changed files with 17 additions and 0 deletions

View File

@@ -63,6 +63,17 @@ final class FlatbuffersVerifierTests: XCTestCase {
XCTAssertThrowsError(try Verifier(buffer: &buffer))
}
func testFailingID() {
let dutData : [UInt8] = [1,2,3,4,5,6,7]
var buff = ByteBuffer(bytes: dutData)
do {
let _: Monster = try getCheckedRoot(byteBuffer: &buff, fileId: "ABCD")
XCTFail("This should always fail")
} catch {
XCTAssertEqual(error as? FlatbuffersErrors, .bufferDoesntContainID)
}
}
func testVerifierCheckAlignment() {
var verifier = try! Verifier(buffer: &buffer)
do {