quark

quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

commit b04ba86f9d5019bb3c9e8543f728b51616745a9f
parent 432898af71af69203f2fa33aa604f0461206e49a
Author: Quentin Rameau <quinq@fifth.space>
Date:   Sat, 22 Jul 2017 01:36:56 +0200

Fix sending of zero-size files

Diffstat:
Mquark.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/quark.c b/quark.c @@ -454,13 +454,13 @@ sendfile(int fd, char *name, struct request *r, struct stat *st, char *mime, "Content-Length: %zu\r\n", s, status_str[s], timestamp(time(NULL), t1), timestamp(st->st_mtim.tv_sec, t2), mime, - upper - lower + (st->st_size > 0)) < 0) { + upper - lower + 1) < 0) { s = S_REQUEST_TIMEOUT; goto cleanup; } if (range) { - if (dprintf(fd, "Content-Range: bytes %zu-%zu/%zu\r\n", - lower, upper, st->st_size) < 0) { + if (dprintf(fd, "Content-Range: bytes %zd-%zd/%zu\r\n", + lower, upper + (upper < 0), st->st_size) < 0) { s = S_REQUEST_TIMEOUT; goto cleanup; }