libmicrohttpd

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

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

response.c: MHD_create_response_from_fd_at_offset64(): don't create response if requested offset or size is not supported

Diffstat:
Msrc/microhttpd/response.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -427,7 +427,15 @@ MHD_create_response_from_fd_at_offset64 (uint64_t size, { struct MHD_Response *response; - response = MHD_create_response_from_callback (size, +#if !defined(HAVE___LSEEKI64) && !defined(HAVE_LSEEK64) + if (sizeof(uint64_t) > sizeof(off_t) && + (size > (uint64_t)INT32_MAX || offset > (uint64_t)INT32_MAX || (size + offset) >= (uint64_t)INT32_MAX)) + return NULL; +#endif + if ((int64_t)size < 0 || (int64_t)offset < 0 || (int64_t)(size + offset) < 0) + return NULL; + + response = MHD_create_response_from_callback(size, 4 * 1024, &file_reader, NULL,