You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

  1. commit 3cd7a1ea5110fc6a92627aaad06553a49723ac92
  2. Author: Christopher Faulet <cfaulet@haproxy.com>
  3. Date: Mon Jul 29 10:50:28 2019 +0200
  4. BUG/MINOR: htx: Fix free space addresses calculation during a block expansion
  5. When the payload of a block is shrinked or enlarged, addresses of the free
  6. spaces must be updated. There are many possible cases. One of them is
  7. buggy. When there is only one block in the HTX message and its payload is just
  8. before the tail room and it needs to be moved in the head room to be enlarged,
  9. addresses are not correctly updated. This bug may be hit by the compression
  10. filter.
  11. This patch must be backported to 2.0.
  12. (cherry picked from commit 61ed7797f6440ee1102576365553650b1982a233)
  13. Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
  14. diff --git a/src/htx.c b/src/htx.c
  15. index c29a66d7..cd21050c 100644
  16. --- a/src/htx.c
  17. +++ b/src/htx.c
  18. @@ -252,11 +252,13 @@ static int htx_prepare_blk_expansion(struct htx *htx, struct htx_blk *blk, int32
  19. ret = 1;
  20. }
  21. else if ((sz + delta) < headroom) {
  22. + uint32_t oldaddr = blk->addr;
  23. +
  24. /* Move the block's payload into the headroom */
  25. blk->addr = htx->head_addr;
  26. htx->tail_addr -= sz;
  27. htx->head_addr += sz + delta;
  28. - if (blk->addr == htx->end_addr) {
  29. + if (oldaddr == htx->end_addr) {
  30. if (htx->end_addr == htx->tail_addr) {
  31. htx->tail_addr = htx->head_addr;
  32. htx->head_addr = htx->end_addr = 0;