mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 00:25:19 +00:00
Merge pull request #96 from Mirza-Samad-Ahmed-Baig/fix/compression-buffer-overflow
Fix: Prevent potential buffer overflow in CompressionUtil.swift
This commit is contained in:
@@ -18,7 +18,8 @@ struct CompressionUtil {
|
||||
// Skip compression for small data
|
||||
guard data.count >= compressionThreshold else { return nil }
|
||||
|
||||
let destinationBuffer = UnsafeMutablePointer<UInt8>.allocate(capacity: data.count)
|
||||
let maxCompressedSize = data.count + (data.count / 255) + 16
|
||||
let destinationBuffer = UnsafeMutablePointer<UInt8>.allocate(capacity: maxCompressedSize)
|
||||
defer { destinationBuffer.deallocate() }
|
||||
|
||||
let compressedSize = data.withUnsafeBytes { sourceBuffer in
|
||||
|
||||
Reference in New Issue
Block a user