Add guard to drop oversized BLE notification assemblies

This commit is contained in:
jack
2025-10-15 00:37:40 +01:00
committed by islam
parent f58bcaf615
commit 640567b7e4
2 changed files with 7 additions and 0 deletions
+6
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
+1
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