libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit cbdf2fe105126821b605098c5fc0d9e0b4b51341
parent 329c4705969983805541d9ed754313574b86ace1
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Tue,  9 Jun 2015 19:34:21 +0000

response.c: file_reader(): reduce read size if buffer is too large

Diffstat:
Msrc/microhttpd/response.c | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -343,7 +343,18 @@ file_reader (void *cls, uint64_t pos, char *buf, size_t max) return MHD_CONTENT_READER_END_WITH_ERROR; /* can't seek to required position */ #endif +#ifndef _WIN32 + if (max > SSIZE_MAX) + max = SSIZE_MAX; + n = read (response->fd, buf, max); +#else /* _WIN32 */ + if (max > INT32_MAX) + max = INT32_MAX; + + n = read (response->fd, buf, (unsigned int)max); +#endif /* _WIN32 */ + if (0 == n) return MHD_CONTENT_READER_END_OF_STREAM; if (n < 0)