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.

56 lines
1.7 KiB

  1. commit c7a203a6c75e4efff5f3d5d675d925f11b47dba1
  2. Author: Frédéric Lécaille <flecaille@haproxy.com>
  3. Date: Thu Apr 2 14:24:31 2020 +0200
  4. BUG/MINOR: protocol_buffer: Wrong maximum shifting.
  5. This patch fixes a bad stop condition when decoding a protocol buffer variable integer
  6. whose maximum lenghts are 10, shifting a uint64_t value by more than 63.
  7. Thank you to Ilya for having reported this issue.
  8. Must be backported to 2.1 and 2.0.
  9. (cherry picked from commit 876ed55d9b8d0c298b6cac1003ec365a19bf7aad)
  10. Signed-off-by: Willy Tarreau <w@1wt.eu>
  11. diff --git a/include/proto/protocol_buffers.h b/include/proto/protocol_buffers.h
  12. index 69f0bdf81..0426d83d2 100644
  13. --- a/include/proto/protocol_buffers.h
  14. +++ b/include/proto/protocol_buffers.h
  15. @@ -158,7 +158,7 @@ protobuf_varint(uint64_t *val, unsigned char *pos, size_t len)
  16. shift += 7;
  17. /* The maximum length in bytes of a 64-bit encoded value is 10. */
  18. - if (shift > 70)
  19. + if (shift > 63)
  20. return 0;
  21. }
  22. @@ -194,7 +194,7 @@ protobuf_decode_varint(uint64_t *val, unsigned char **pos, size_t *len)
  23. shift += 7;
  24. /* The maximum length in bytes of a 64-bit encoded value is 10. */
  25. - if (shift > 70)
  26. + if (shift > 63)
  27. return 0;
  28. }
  29. @@ -227,7 +227,7 @@ protobuf_skip_varint(unsigned char **pos, size_t *len, size_t vlen)
  30. shift += 7;
  31. /* The maximum length in bytes of a 64-bit encoded value is 10. */
  32. - if (shift > 70)
  33. + if (shift > 63)
  34. return 0;
  35. }
  36. @@ -263,7 +263,7 @@ protobuf_varint_getlen(unsigned char *pos, size_t len)
  37. shift += 7;
  38. /* The maximum length in bytes of a 64-bit encoded value is 10. */
  39. - if (shift > 70)
  40. + if (shift > 63)
  41. return -1;
  42. }