aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-20 16:04:06 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-20 16:04:06 +0000
commit602e9c682982c4a3b2c232d5d384e4f16698fdaf (patch)
treea1c2adfa56d3f64af9ce6b9232ddd2045434b7a3
parent4eede83e0de5e77b6680c5d16247db23a167d0ec (diff)
downloadlibmicrohttpd-602e9c682982c4a3b2c232d5d384e4f16698fdaf.tar.gz
libmicrohttpd-602e9c682982c4a3b2c232d5d384e4f16698fdaf.zip
-fix issue with sendfile incrementing buffer offset when it should not
-rw-r--r--src/microhttpd/connection.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index f8059dbc..69ea54e5 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1551,12 +1551,13 @@ static int
1551do_write (struct MHD_Connection *connection) 1551do_write (struct MHD_Connection *connection)
1552{ 1552{
1553 int ret; 1553 int ret;
1554 size_t max;
1554 1555
1556 max = connection->write_buffer_append_offset - connection->write_buffer_send_offset;
1555 ret = connection->send_cls (connection, 1557 ret = connection->send_cls (connection,
1556 &connection->write_buffer 1558 &connection->write_buffer
1557 [connection->write_buffer_send_offset], 1559 [connection->write_buffer_send_offset],
1558 connection->write_buffer_append_offset 1560 max);
1559 - connection->write_buffer_send_offset);
1560 1561
1561 if (ret < 0) 1562 if (ret < 0)
1562 { 1563 {
@@ -1582,7 +1583,10 @@ do_write (struct MHD_Connection *connection)
1582 ret, 1583 ret,
1583 &connection->write_buffer[connection->write_buffer_send_offset]); 1584 &connection->write_buffer[connection->write_buffer_send_offset]);
1584#endif 1585#endif
1585 connection->write_buffer_send_offset += ret; 1586 /* only increment if this wasn't a "sendfile" transmission without
1587 buffer involvement! */
1588 if (0 != max)
1589 connection->write_buffer_send_offset += ret;
1586 return MHD_YES; 1590 return MHD_YES;
1587} 1591}
1588 1592