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.

32 lines
1.6 KiB

  1. commit 64a7cbf4ea3276b72ffb121acab676542cebde1b
  2. Author: Willy Tarreau <w@1wt.eu>
  3. Date: Tue Nov 20 04:47:38 2018 +0100
  4. BUG/MEDIUM: hpack: fix encoding of "accept-ranges" field
  5. James Brown reported that when an "accept-ranges" header field is sent
  6. through haproxy and converted from HTTP/1.1 to H2, it's mis-encoded as
  7. "accept-language". It happens that it's one of the few very common header
  8. fields encoded using its index value and that this index value was misread
  9. in the spec as 17 instead of 18, resulting in the wrong name being sent.
  10. Thanks to Lukas for spotting the issue in the HPACK encoder itself.
  11. This fix must be backported to 1.8.
  12. (cherry picked from commit 4bf194cbdbcda8ec4ce83d7f12d2fe9b08483c94)
  13. [wla: buffer API edit]
  14. Signed-off-by: William Lallemand <wlallemand@haproxy.org>
  15. diff --git a/src/hpack-enc.c b/src/hpack-enc.c
  16. index d1f68c58..99c73103 100644
  17. --- a/src/hpack-enc.c
  18. +++ b/src/hpack-enc.c
  19. @@ -101,7 +101,7 @@ int hpack_encode_header(struct chunk *out, const struct ist n, const struct ist
  20. else if (isteq(n, ist("last-modified")))
  21. out->str[len++] = 0x6c; // literal with indexing -- name="last-modified" (idx 44)
  22. else if (isteq(n, ist("accept-ranges")))
  23. - out->str[len++] = 0x51; // literal with indexing -- name="accept-ranges" (idx 17)
  24. + out->str[len++] = 0x52; // literal with indexing -- name="accept-ranges" (idx 18)
  25. else if (isteq(n, ist("cache-control")))
  26. out->str[len++] = 0x58; // literal with indexing -- name="cache-control" (idx 24)
  27. else if (isteq(n, ist("content-length")))