lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.92k stars 549 forks source link

Files larger than the maximum size_t are cut off silently #42

Closed TyRoXx closed 10 years ago

TyRoXx commented 10 years ago

(This is about revision e380a8c.) Excuse me if I am mistaken, but it seems that the length of a file delivered using sendfile is implicitly capped by the capacity of size_t.

common/lwan-serve-files.c:778

lwan_sendfile(request, file_fd, from, (size_t)to);

to is an off_t which seems to be the correct type for a file size. On systems where sizeof(size_t) < sizeof(off_t) the truncating cast makes it impossible to deliver file ranges longer than SIZE_T_MAX correctly. On 32-bit systems SIZE_T_MAX is typically 2^32-1 which would be an archaic file size limit.

lpereira commented 10 years ago

You're right. I'll use a type that's guaranteed to be 64-bit, unsigned, regardless of word size.