Add guard to drop oversized BLE notification assemblies

This commit is contained in:
jack 2025-09-25 01:45:37 +02:00 committed by islam
parent 209f926990
commit 3b2c7d2f73
2 changed files with 7 additions and 0 deletions

View File

@ -15,6 +15,12 @@ struct NotificationStreamAssembler {
buffer.append(chunk)
if buffer.count > TransportConfig.bleNotificationAssemblerHardCapBytes {
SecureLogger.error("❌ Notification assembler overflow (\(buffer.count) bytes); dropping partial frame", category: .session)
buffer.removeAll(keepingCapacity: false)
return ([], [], true)
}
var frames: [Data] = []
var dropped: [UInt8] = []
var reset = false

View File

@ -30,6 +30,7 @@ enum TransportConfig {
static let bleDynamicRSSIThresholdDefault: Int = -90
static let bleConnectionCandidatesMax: Int = 100
static let blePendingWriteBufferCapBytes: Int = 1_000_000
static let bleNotificationAssemblerHardCapBytes: Int = 8 * 1024 * 1024
static let blePendingNotificationsCapCount: Int = 20
// Nostr