libmicrohttpd

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

commit 602e9c682982c4a3b2c232d5d384e4f16698fdaf
parent 4eede83e0de5e77b6680c5d16247db23a167d0ec
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 20 Dec 2013 16:04:06 +0000

-fix issue with sendfile incrementing buffer offset when it should not

Diffstat:
Msrc/microhttpd/connection.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -1551,12 +1551,13 @@ static int do_write (struct MHD_Connection *connection) { int ret; + size_t max; + max = connection->write_buffer_append_offset - connection->write_buffer_send_offset; ret = connection->send_cls (connection, &connection->write_buffer [connection->write_buffer_send_offset], - connection->write_buffer_append_offset - - connection->write_buffer_send_offset); + max); if (ret < 0) { @@ -1582,7 +1583,10 @@ do_write (struct MHD_Connection *connection) ret, &connection->write_buffer[connection->write_buffer_send_offset]); #endif - connection->write_buffer_send_offset += ret; + /* only increment if this wasn't a "sendfile" transmission without + buffer involvement! */ + if (0 != max) + connection->write_buffer_send_offset += ret; return MHD_YES; }