Merge 4d463b0ce155e8a9c85dd96c23df139c9294ed95 into 9b84b361225facd8e623f25d76f889d3dc54a879

This commit is contained in:
Eric Gang 2026-08-11 09:05:57 +02:00 committed by GitHub
commit 02dbe386ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -366,7 +366,19 @@ public struct BinaryProtocol {
guard let rawSize = read16() else { return nil }
originalSize = Int(rawSize)
}
guard originalSize >= 0 && originalSize <= FileTransferLimits.maxFramedFileBytes else { return nil }
// Logged, not silent: this is the sibling of the ratio
// rejection below and drops the packet just as completely, but
// returning `nil` bare left no trace anywhere. A peer whose
// ceiling is higher than ours (issue #1618: Android permits a
// 10 MiB expanded payload against our ~1.13 MiB) then looks to
// both sides like a message that simply never arrived.
guard originalSize >= 0 && originalSize <= FileTransferLimits.maxFramedFileBytes else {
SecureLogger.warning(
"🚫 Declared expanded payload \(originalSize) B exceeds the \(FileTransferLimits.maxFramedFileBytes) B ceiling",
category: .security
)
return nil
}
let compressedSize = payloadLength - lengthFieldBytes
guard compressedSize > 0, let compressed = readData(compressedSize) else { return nil }