summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pttbbs/daemon/boardd/boardd.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/pttbbs/daemon/boardd/boardd.c b/pttbbs/daemon/boardd/boardd.c
index d9f20d56..1d63eab0 100644
--- a/pttbbs/daemon/boardd/boardd.c
+++ b/pttbbs/daemon/boardd/boardd.c
@@ -105,6 +105,11 @@ answer_file(struct evbuffer *buf, const char *path, struct stat *st,
if (maxlen < 0 || offset + maxlen > st->st_size)
maxlen = st->st_size - offset;
+ if (maxlen == 0) {
+ close(fd);
+ return 0;
+ }
+
if (evbuffer_add_file(buf, fd, offset, maxlen) == 0)
return 0;