)]}'
{
  "commit": "25ff0f4f0fc86e1d13651567232b6d85cb91a331",
  "tree": "ccaa6c61cb5a946f3c256c51356a7e23a1f7da3b",
  "parents": [
    "2a47e00749dc867e60603fd2c7a6cd2710c780b6"
  ],
  "author": {
    "name": "Maxim Dounin",
    "email": "mdounin@mdounin.ru",
    "time": "Fri Jan 20 21:12:48 2017 +0300"
  },
  "committer": {
    "name": "Maxim Dounin",
    "email": "mdounin@mdounin.ru",
    "time": "Fri Jan 20 21:12:48 2017 +0300"
  },
  "message": "Fixed trailer construction with limit on FreeBSD and macOS.\n\nThe ngx_chain_coalesce_file() function may produce more bytes to send then\nrequested in the limit passed, as it aligns the last file position\nto send to memory page boundary.  As a result, (limit - send) may become\nnegative.  This resulted in big positive number when converted to size_t\nwhile calling ngx_output_chain_to_iovec().\n\nAnother part of the problem is in ngx_chain_coalesce_file(): it changes cl\nto the next chain link even if the current buffer is only partially sent\ndue to limit.\n\nTherefore, if a file buffer was not expected to be fully sent due to limit,\nand was followed by a memory buffer, nginx called sendfile() with a part\nof the file buffer, and the memory buffer in trailer.  If there were enough\nroom in the socket buffer, this resulted in a part of the file buffer being\nskipped, and corresponding part of the memory buffer sent instead.\n\nThe bug was introduced in 8e903522c17a (1.7.8).  Configurations affected\nare ones using limits, that is, limit_rate and/or sendfile_max_chunk, and\nmemory buffers after file ones (may happen when using subrequests or\nwith proxying with disk buffering).\n\nFix is to explicitly check if (send \u003c limit) before constructing trailer\nwith ngx_output_chain_to_iovec().  Additionally, ngx_chain_coalesce_file()\nwas modified to preserve unfinished file buffers in cl.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d30a0a4fcad679d05244811adb8813e6ff1ddefb",
      "old_mode": 33188,
      "old_path": "src/core/ngx_buf.c",
      "new_id": "1862a0606ab531f79ad4cfc0ae37f732c9fb8526",
      "new_mode": 33188,
      "new_path": "src/core/ngx_buf.c"
    },
    {
      "type": "modify",
      "old_id": "c802e9f9a163dff8627651a55424db35e4255ed1",
      "old_mode": 33188,
      "old_path": "src/os/unix/ngx_darwin_sendfile_chain.c",
      "new_id": "2a76c154dd2326d8ce46b43fa7eae584c3c0440b",
      "new_mode": 33188,
      "new_path": "src/os/unix/ngx_darwin_sendfile_chain.c"
    },
    {
      "type": "modify",
      "old_id": "d0299f54fa9c3893e4e910d84864a553a19862c6",
      "old_mode": 33188,
      "old_path": "src/os/unix/ngx_freebsd_sendfile_chain.c",
      "new_id": "4822e72bb82802a6a6979c3b5994f3d59c6f83f8",
      "new_mode": 33188,
      "new_path": "src/os/unix/ngx_freebsd_sendfile_chain.c"
    }
  ]
}
