pmusolino / Wormholy

iOS network debugging, like a wizard 🧙‍♂️
MIT License
2.32k stars 184 forks source link

Integer Overflow Issue when Uploading a file #76

Closed EugeneNaloiko closed 3 years ago

EugeneNaloiko commented 4 years ago

In the method: private func body(from request: URLRequest) -> Data? { return request.httpBody ?? request.httpBodyStream.flatMap { stream in let data = NSMutableData() stream.open() while stream.hasBytesAvailable { var buffer = [UInt8](repeating: 0, count: 1024) let length = stream.read(&buffer, maxLength: buffer.count) data.append(buffer, length: length) } stream.close() return data as Data } } In the row "data.append(buffer, length: length)"

I'm getting a crash, when my app is uploading a chunk of data:

Terminating app due to uncaught exception 'NSRangeException', reason: ' -[NSConcreteMutableData appendBytes:length:]: range {204800, 18446744073709551615} causes integer overflow'

The file is not so big - a photo sent as a single chunk.

pmusolino commented 3 years ago

Hi there. If you try the latest version available (1.6.4 in this moment), the issue should be solved.