From 4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd Mon Sep 17 00:00:00 2001
From: robertabcd <robertabcd@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>
Date: Sun, 5 Oct 2014 18:27:08 +0000
Subject: boardd: don't add fd to buffer when maxlen is zero.

git-svn-id: http://opensvn.csie.org/pttbbs/trunk@6079 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
---
 pttbbs/daemon/boardd/boardd.c | 5 +++++
 1 file changed, 5 insertions(+)

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;
 
-- 
cgit v1.2.3