mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 06:05:20 +00:00
Add guard to drop oversized BLE notification assemblies
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user