diff options
author | robertabcd <robertabcd@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2014-10-06 02:27:08 +0800 |
---|---|---|
committer | robertabcd <robertabcd@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2014-10-06 02:27:08 +0800 |
commit | 4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd (patch) | |
tree | 1c8c949ce7074173c04f9007661eac3974bd9292 | |
parent | 17d9838b48aac4b40f806350eddd36b4a09ad47b (diff) | |
download | pttbbs-4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd.tar pttbbs-4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd.tar.gz pttbbs-4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd.tar.bz2 pttbbs-4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd.tar.lz pttbbs-4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd.tar.xz pttbbs-4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd.tar.zst pttbbs-4f3a8f3b4c61825d40543f8f0ff0ba53981d90fd.zip |
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
-rw-r--r-- | pttbbs/daemon/boardd/boardd.c | 5 |
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; |