Fix possible overflow on lineWritten

Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
This commit is contained in:
Claudio Cambra 2022-05-18 16:08:12 +02:00
parent 5523330d65
commit 1f04073e7c
1 changed files with 2 additions and 2 deletions

View File

@ -207,9 +207,9 @@
NSLog(@"About to write %li bytes from outbuffer to socket.", [self.outBuffer length]);
long bytesWritten = write(self.sock, [self.outBuffer bytes], [self.outBuffer length]);
char lineWritten[4096];
char lineWritten[[self.outBuffer length]];
memcpy(lineWritten, [self.outBuffer bytes], [self.outBuffer length]);
NSLog(@"Wrote %li bytes to socket. Line was: '%@'", bytesWritten, [NSString stringWithUTF8String:lineWritten]);
NSLog(@"Wrote %li bytes to socket. Line written was: '%@'", bytesWritten, [NSString stringWithUTF8String:lineWritten]);
if(bytesWritten == 0) {
// 0 means we reached "end of file" and thus the socket was closed. So let's restart it