)]}'
{
  "commit": "97438e423f66260151dd1ecfcda4c312a841f0fb",
  "tree": "c24e608c85dee56b732a88d0f2a3cf32b7ddc7e7",
  "parents": [
    "ed5e9b8d8b5a3b641704b4423d01ebaaba3e99d3"
  ],
  "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": "00b6644585ab6a975a155f24a877f7168026db65",
      "old_mode": 33188,
      "old_path": "src/core/ngx_buf.c",
      "new_id": "418411b7b061e5bff1e09c36d20fd58b749fa93b",
      "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"
    }
  ]
}
