[hackers] [quark] Fix sending of zero-size files || Quentin Rameau

From: <git_AT_suckless.org>
Date: Sat, 22 Jul 2017 13:32:11 +0200 (CEST)

commit b04ba86f9d5019bb3c9e8543f728b51616745a9f
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sat Jul 22 01:36:56 2017 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
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
_AT_@ -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;
                 }
Received on Sat Jul 22 2017 - 13:32:11 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 22 2017 - 13:38:32 CEST