TCBlobDownload icon indicating copy to clipboard operation
TCBlobDownload copied to clipboard

Bug found in connection:didReceiveResponse:

Open ylisr opened this issue 10 years ago • 1 comments

Hi Thibault, thanks for the project, I've been using it for a while and it's wonderful.

Recently I've noticed some suspicious crashes happening and I'm able to narrow it down to the callback block of startDownloadWithURL:customPath:firstResponse:progress:error:complete:method. Turns out the totalLength parameter in progressBlock sometimes returns the maximum value of UInt64, so when I assign it to a 64-bit NSNumber, it causes a segmentation fault.

on Line 205 of TCBlobDownload.m I found:

self.expectedDataLength = self.receivedDataLength + [response expectedContentLength];

the expectedContentLength property of NSURLResponse returns -1 if there is no expectation that can be arrived, at the same time if I pause and resume a download, sometimes receivedDataLength could be 0 (not sure why), so here you could be assigning minus value to expectedDataLength which is a uint64_t. I suggest to check the value before the assignment.

Meanwhile,I'm using TCBlobDownload in my swift project at the moment. I should take your advice and switch to the newest swift version. Again thanks for your hard work :)

ylisr avatar Apr 08 '15 03:04 ylisr

Thanks for noticing this. I will maybe find some time to fix it.

thibaultcha avatar Nov 12 '15 08:11 thibaultcha