Check device message size

This commit is contained in:
Christoph Hagen 2023-12-08 15:53:01 +01:00
parent 7652bb24a3
commit 2e11023096

View File

@ -113,12 +113,17 @@ final class DeviceManager {
}
func processDeviceResponse(_ buffer: ByteBuffer) {
guard let data = buffer.getData(at: 0, length: buffer.readableBytes),
data.count == SignedMessage.size else {
guard let data = buffer.getData(at: 0, length: buffer.readableBytes) else {
log("Failed to get data buffer received from device")
self.resumeDeviceRequest(with: .invalidMessageSizeFromDevice)
return
}
guard data.count == SignedMessage.size else {
print("Invalid size of device message: \(data.count)")
self.resumeDeviceRequest(with: .invalidMessageSizeFromDevice)
return
}
self.resumeDeviceRequest(with: data)
}