commit b04ba86f9d5019bb3c9e8543f728b51616745a9f
Author:     Quentin Rameau <[email protected]>
AuthorDate: Sat Jul 22 01:36:56 2017 +0200
Commit:     Laslo Hunhold <[email protected]>
CommitDate: Sat Jul 22 13:32:06 2017 +0200

    Fix sending of zero-size files

diff --git a/quark.c b/quark.c
index c7681e5..5351bd8 100644
--- 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;
                }

Reply via email to