-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CBOR decode crashes #92
Comments
This can be a tricky one, especially with the sort of pathological case you've got in your code above. For example, if you take this code and run it as a test: func testDecodeBadBytes() {
let length = 10000
let randomUInt: UInt8 = 202
let randomData = Data([UInt8](repeating: randomUInt, count: length))
let result = try? CBOR.decode([UInt8](randomData))
XCTAssertNotNil(result)
} then you'll get a crash like the one you described. This is because If you take that example from above and only change the value of I don't know what the best approach would be here to try and avoid the crashes. It would need more investigation and I don't currently have time for that I'm afraid. |
I have a fix in #101, verified using both suggested tests. |
When passing random data to
CBOR.decode()
the entire app just crashes with anEXC_BAD_ACCESS (code=2, address=0x16f603f60)
Is that intended? If so, how can I add a safety check?
Example:
The text was updated successfully, but these errors were encountered: